diff --git a/multimedia/media/media_js_standard/videoDecoder/BUILD.gn b/multimedia/media/media_js_standard/videoDecoder/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..221525ca01232dfe21c5f4f5568b1a78d638f8d5
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/BUILD.gn
@@ -0,0 +1,31 @@
+# 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_decoder_js_hap") {
+ hap_profile = "./src/main/config.json"
+ js2abc = true
+ deps = [
+ ":video_decoder_js_assets",
+ ":video_decoder_resources",
+ ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "VideoDecoderJsTest"
+}
+ohos_js_assets("video_decoder_js_assets") {
+ source_dir = "./src/main/js/default"
+}
+ohos_resources("video_decoder_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/multimedia/media/media_js_standard/videoDecoder/Test.json b/multimedia/media/media_js_standard/videoDecoder/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..9cffa6f1721499aee187f6954872ebe91b23f813
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/Test.json
@@ -0,0 +1,40 @@
+{
+ "description": "Configuration for video decoder Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "2000000",
+ "package": "ohos.acts.multimedia.videodecoder",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "type": "PushKit",
+ "pre-push": [
+ ],
+ "push": [
+ "./resource/media/es/out_1920_1080_30fps_3s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/",
+ "./resource/media/es/h263_1408_1152.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/",
+ "./resource/media/es/MPEG2_720_480.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/",
+ "./resource/media/es/mpeg4_320_240.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/",
+ "./resource/media/es/out_320_240_10s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/"
+ ]
+ },
+ {
+ "type": "ShellKit",
+ "run-command": [
+ "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/",
+ "setenforce 0"
+ ],
+ "teardown-command":[
+ "setenforce 1"
+ ]
+ },
+ {
+ "test-file-name": [
+ "MediaVideoDecoderJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
diff --git a/multimedia/media/media_js_standard/videoDecoder/signature/openharmony_sx.p7b b/multimedia/media/media_js_standard/videoDecoder/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/multimedia/media/media_js_standard/videoDecoder/signature/openharmony_sx.p7b differ
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/config.json b/multimedia/media/media_js_standard/videoDecoder/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..47d898fd6b7b3364c9658f0f8663ebbb477d7223
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/config.json
@@ -0,0 +1,75 @@
+{
+ "app": {
+ "apiVersion": {
+ "compatible": 6,
+ "releaseType": "Beta1",
+ "target": 7
+ },
+ "vendor": "acts",
+ "bundleName": "ohos.acts.multimedia.videodecoder",
+ "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.videodecoder.MainAbility",
+ "description": "$string:mainability_description",
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "homeAbility": true,
+ "launchType": "standard"
+ }
+ ],
+ "deviceType": [
+ "phone",
+ "tablet",
+ "tv",
+ "wearable"
+ ],
+ "mainAbility": "ohos.acts.multimedia.videodecoder.MainAbility",
+ "distro": {
+ "moduleType": "entry",
+ "installationFree": false,
+ "deliveryWithInstall": true,
+ "moduleName": "entry"
+ },
+ "package": "ohos.acts.multimedia.videodecoder",
+ "name": ".MyApplication",
+ "js": [
+ {
+ "pages": [
+ "pages/index/index",
+ "pages/display/display"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/app.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/js/default/i18n/en-US.json b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/js/default/i18n/zh-CN.json b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/js/default/pages/display/display.css b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.css
new file mode 100644
index 0000000000000000000000000000000000000000..5bd7567028568bd522193b2519d545ca6dcf397d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.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/videoDecoder/src/main/js/default/pages/display/display.hml b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.hml
new file mode 100644
index 0000000000000000000000000000000000000000..bd41a500e2ef4d3c7a11f37611a403e5bb2bfc43
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.hml
@@ -0,0 +1,11 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
+
+
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.js
new file mode 100644
index 0000000000000000000000000000000000000000..ac3d0fc9c890432e49e4a9ef0ea52922903b5a4f
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.js
@@ -0,0 +1,33 @@
+/*
+ * 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() {
+ console.info('onInit finish')
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ },
+ onReady() {
+ },
+ LoadXcomponent() {
+ globalThis.value = this.$element('XcomponentId').getXComponentSurfaceId();
+ },
+}
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.css b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..5bd7567028568bd522193b2519d545ca6dcf397d
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/js/default/pages/index/index.hml b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..06e991ff50e322e9b6acf33010b6c32bc168e200
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/index/index.js
@@ -0,0 +1,42 @@
+/*
+ * 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() {
+ console.info('onInit finish')
+ 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/videoDecoder/src/main/js/test/List.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..35a04e3b2075a7e5a22c3a206afcba863f6e060f
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/List.test.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.
+ */
+
+require('./VideoDecoderFuncCallbackTest.test.js')
+require('./VideoDecoderFuncPromiseTest.test.js')
+require('./VideoDecoderReliCallbackTest.test.js')
+require('./VideoDecoderReliPromiseTest.test.js')
+require('./VideoDecoderSoftwareFuncCallbackTest.test.js')
+require('./VideoDecoderSoftwareFuncPromiseTest.test.js')
+require('./VideoDecoderSoftwareReliCallbackTest.test.js')
+require('./VideoDecoderSoftwareReliPromiseTest.test.js')
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4fc7a63f66b97576b3dd3c2f45bc25056e27b1cf
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
@@ -0,0 +1,466 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('VideoDecoderFuncCallbackTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = false;
+ let inputEosFlag = false;
+ let surfaceID = '';
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ let ES_FRAME_SIZE = [];
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ const H263_FRAME_SIZE =
+ [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244,
+ 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165,
+ 24267, 36171, 18330, 53228, 7893, 13088, 9502, 8485, 9207, 8681, 9202, 8537, 7603, 9726, 8191, 51872,
+ 5535, 6146, 6341, 6933, 9365, 7828, 6547, 7638, 7009, 7025, 8873, 51045, 5056, 4858, 4887, 9614, 5953,
+ 5972, 6116, 6060, 6296, 6239, 6400, 50928, 4937, 5054, 5371, 6728, 6286, 6524, 6646, 6549, 6036, 6214,
+ 5866, 51109, 4778, 5273, 6327];
+ const MPEG2_FRAME_SIZE =
+ [ 38462, 55096, 8660, 3417, 1197, 2209, 984, 718, 783, 623, 659, 694, 14174, 580, 421, 495, 480, 476, 534,
+ 660, 699, 601, 603, 720, 12585, 555, 532, 776, 789, 762, 766, 732, 671, 735, 777, 948, 12650, 827, 766,
+ 835, 747, 847, 940, 1121, 1092, 1001, 980, 989, 12746, 945, 912, 1046, 1118, 1134, 1050, 1073, 1051, 1195,
+ 1085, 1182, 12874, 992, 1007, 985, 1040, 1143, 1157, 1150, 1247, 1149, 1246, 1145, 12870, 1041, 1066, 1314,
+ 1239, 1283, 1223, 1224, 1270, 1427, 1406, 1516, 12949, 1228, 1299, 1439, 1358, 1455, 1311, 1396, 1416, 1470,
+ 1393, 1502, 12999, 1232, 1400, 1348, 1335, 1461, 1404, 1412, 1426, 1548, 1481, 1488, 12840, 1229, 1342, 1323,
+ 1353, 1524, 1363, 1475, 1540, 1495, 1489, 1438, 12762, 1291, 1303, 1470, 1494, 1488, 1474, 1453, 1607, 1485,
+ 1589, 1762, 12548, 1363, 1317, 1435, 1411, 1338, 1373, 1605, 1639, 1429, 1392, 1543, 12332, 1255, 1200, 1291,
+ 1337, 1341, 1356, 1214, 1456, 1353, 1314, 1502, 12151, 1192, 1290, 1203, 1284, 1154, 1264, 1358, 1390, 1433,
+ 1194, 1325, 11904, 993, 1007, 1149, 1099, 1182, 1076, 1074, 1092, 1030, 1272, 1178, 11710, 966, 879, 860, 955,
+ 898, 967, 927, 1066, 997, 1083, 940, 11717, 648, 705, 901, 925, 930, 868, 798, 846, 781, 825, 1027, 11587, 785,
+ 733, 731, 848, 753, 806, 699, 837, 750, 762, 748, 11541, 678, 742, 667, 735, 702, 837, 695, 773, 849, 869, 769,
+ 11381, 664, 705, 714, 698, 814, 846, 757, 802, 857, 905, 772, 11265, 718, 643, 597, 687, 774, 843, 747, 785,
+ 683, 1135, 676, 11259, 616, 595, 773, 746, 798, 722, 798, 790, 959, 771, 907, 11234, 705, 675, 773, 764, 846,
+ 789, 840, 853, 828, 774, 842, 11263, 758, 758, 757, 820, 847, 834, 884, 842, 988, 750, 952, 11236, 776, 640, 727,
+ 832, 855, 733, 822, 827, 862, 697, 924, 11176, 675, 615, 688, 818, 783, 746, 901, 834, 892, 759, 923, 11181, 661,
+ 578, 720, 697];
+ const MPEG4_FRAME_SIZE =
+ [ 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959,
+ 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451,
+ 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317,
+ 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401,
+ 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423,
+ 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439,
+ 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268,
+ 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334,
+ 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287,
+ 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302,
+ 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259,
+ 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433,
+ 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287,
+ 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235,
+ 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228,
+ 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719];
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = false;
+ inputEosFlag = false;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ let failCatch = function(err) {
+ console.info(`in case error failCatch called,errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: filepath ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case error readFile' + e);
+ }
+ }
+ function getContent(buf, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ lengthReal = readStreamSync.readSync(
+ buf,
+ {length: len}
+ );
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent: ' + e);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs(){
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 16.67;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ if (frameCountIn == ES_FRAME_SIZE.length / 2) {
+ videoDecodeProcessor.setParameter({
+ 'bitrate': 6400,
+ }, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case: setParameter success ');
+ });
+ }
+ videoDecodeProcessor.queueInput(inputObject, (err) => {
+ if (typeof (err) == 'undefined') {
+ console.info('in case: queueInput success ');
+ } else {
+ console.info(`in case queueInput err called,errMessage is ${error.message}`);
+ }
+ })
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep){
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ nextStep();
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true, (err) => {
+ if (typeof (err) == 'undefined') {
+ console.log('in case: release output count:' + frameCountOut);
+ } else {
+ console.info(`in case releaseOutput error called,errMessage is ${error.message}`);
+ }
+ })
+ }
+ }
+
+ function setCallback(nextStep){
+ console.info('in case: setCallback in');
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ videoDecodeProcessor.getOutputMediaDescription((err, MediaDescription) => {
+ expect(err).assertUndefined();
+ console.info('get outputMediaDescription : ' + MediaDescription);
+ });
+ outputQueue.push(outBuffer);
+ dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ console.info('in case: setCallback out');
+ }
+ eventEmitter.on('configure', (mediaDescription, srcPath, nextStep, done) => {
+ console.info('in case : configure in');
+ videoDecodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : configure success');
+ readFile(srcPath);
+ setCallback(nextStep);
+ eventEmitter.emit('getVideoDecoderCaps', done);
+ // eventEmitter.emit('setOutputSurface', done);
+ });
+ });
+ eventEmitter.on('getVideoDecoderCaps', (done) => {
+ videoDecodeProcessor.getVideoDecoderCaps((err, videoCaps) => {
+ expect(err).assertUndefined();
+ console.info('case get getVideoDecoderCaps 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('setOutputSurface', done);
+ });
+ });
+
+ eventEmitter.on('setOutputSurface', (done) => {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : setOutputSurface success, surfaceID ' + surfaceID);
+ eventEmitter.emit('prepare', done);
+ })
+ });
+ eventEmitter.on('prepare', (done) => {
+ videoDecodeProcessor.prepare((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : prepare success');
+ eventEmitter.emit('start', done);
+ });
+ });
+ eventEmitter.on('start', (done) => {
+ videoDecodeProcessor.start((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : start success');
+ });
+ });
+ eventEmitter.on('stop', (done) => {
+ videoDecodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : stop success');
+ eventEmitter.emit('reset', done);
+ });
+ });
+ eventEmitter.on('reset', (done) => {
+ videoDecodeProcessor.reset((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset success');
+ eventEmitter.emit('release', done);
+ });
+ });
+ eventEmitter.on('release', (done) => {
+ videoDecodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : release success');
+ videoDecodeProcessor = null;
+ done();
+ });
+ });
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_H264_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_H264_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 4,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByMime('video/avc', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByMime success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ },
+ done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_H263_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_H263_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H263_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'h263_1408_1152.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/h263',
+ 'width': 1408,
+ 'height': 1152,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByMime('video/h263', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByMime success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ },
+ done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_MPEG2_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_MPEG2_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG2_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'MPEG2_720_480.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mpeg2',
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByMime('video/mpeg2', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByMime success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ },
+ done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_MPEG4_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_MPEG4_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG4_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'mpeg4_320_240.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mp4v-es',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByMime('video/mp4v-es', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByMime success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ },
+ done);
+ });
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0466853560d1e2fc31d7e755144a69104be82952
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
@@ -0,0 +1,519 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+
+describe('VideoDecoderFuncPromiseTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = false;
+ let inputEosFlag = false;
+ let surfaceID = '';
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ let ES_FRAME_SIZE = [];
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ const H263_FRAME_SIZE =
+ [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244,
+ 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165,
+ 24267, 36171, 18330, 53228, 7893, 13088, 9502, 8485, 9207, 8681, 9202, 8537, 7603, 9726, 8191, 51872,
+ 5535, 6146, 6341, 6933, 9365, 7828, 6547, 7638, 7009, 7025, 8873, 51045, 5056, 4858, 4887, 9614, 5953,
+ 5972, 6116, 6060, 6296, 6239, 6400, 50928, 4937, 5054, 5371, 6728, 6286, 6524, 6646, 6549, 6036, 6214,
+ 5866, 51109, 4778, 5273, 6327];
+ const MPEG2_FRAME_SIZE =
+ [ 38462, 55096, 8660, 3417, 1197, 2209, 984, 718, 783, 623, 659, 694, 14174, 580, 421, 495, 480, 476, 534,
+ 660, 699, 601, 603, 720, 12585, 555, 532, 776, 789, 762, 766, 732, 671, 735, 777, 948, 12650, 827, 766,
+ 835, 747, 847, 940, 1121, 1092, 1001, 980, 989, 12746, 945, 912, 1046, 1118, 1134, 1050, 1073, 1051, 1195,
+ 1085, 1182, 12874, 992, 1007, 985, 1040, 1143, 1157, 1150, 1247, 1149, 1246, 1145, 12870, 1041, 1066, 1314,
+ 1239, 1283, 1223, 1224, 1270, 1427, 1406, 1516, 12949, 1228, 1299, 1439, 1358, 1455, 1311, 1396, 1416, 1470,
+ 1393, 1502, 12999, 1232, 1400, 1348, 1335, 1461, 1404, 1412, 1426, 1548, 1481, 1488, 12840, 1229, 1342, 1323,
+ 1353, 1524, 1363, 1475, 1540, 1495, 1489, 1438, 12762, 1291, 1303, 1470, 1494, 1488, 1474, 1453, 1607, 1485,
+ 1589, 1762, 12548, 1363, 1317, 1435, 1411, 1338, 1373, 1605, 1639, 1429, 1392, 1543, 12332, 1255, 1200, 1291,
+ 1337, 1341, 1356, 1214, 1456, 1353, 1314, 1502, 12151, 1192, 1290, 1203, 1284, 1154, 1264, 1358, 1390, 1433,
+ 1194, 1325, 11904, 993, 1007, 1149, 1099, 1182, 1076, 1074, 1092, 1030, 1272, 1178, 11710, 966, 879, 860, 955,
+ 898, 967, 927, 1066, 997, 1083, 940, 11717, 648, 705, 901, 925, 930, 868, 798, 846, 781, 825, 1027, 11587, 785,
+ 733, 731, 848, 753, 806, 699, 837, 750, 762, 748, 11541, 678, 742, 667, 735, 702, 837, 695, 773, 849, 869, 769,
+ 11381, 664, 705, 714, 698, 814, 846, 757, 802, 857, 905, 772, 11265, 718, 643, 597, 687, 774, 843, 747, 785,
+ 683, 1135, 676, 11259, 616, 595, 773, 746, 798, 722, 798, 790, 959, 771, 907, 11234, 705, 675, 773, 764, 846,
+ 789, 840, 853, 828, 774, 842, 11263, 758, 758, 757, 820, 847, 834, 884, 842, 988, 750, 952, 11236, 776, 640, 727,
+ 832, 855, 733, 822, 827, 862, 697, 924, 11176, 675, 615, 688, 818, 783, 746, 901, 834, 892, 759, 923, 11181, 661,
+ 578, 720, 697];
+ const MPEG4_FRAME_SIZE =
+ [ 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959,
+ 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451,
+ 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317,
+ 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401,
+ 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423,
+ 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439,
+ 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268,
+ 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334,
+ 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287,
+ 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302,
+ 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259,
+ 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433,
+ 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287,
+ 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235,
+ 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228,
+ 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719];
+ beforeAll(function() {
+ console.info('beforeAll case');
+ // getSurfaceID();
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = false;
+ inputEosFlag = false;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ let failCatch = function(err) {
+ console.info(`in case error failCatch called,errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: filepath ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.error('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ lengthReal = readStreamSync.readSync(
+ buf,
+ {length: len}
+ );
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent ' + e);
+ }
+ }
+ function getSurfaceID() {
+ let surfaceIDTest = new ArrayBuffer(20);
+ let readSurfaceID = Fileio.createStreamSync('/data/media/surfaceID.txt', 'rb');
+ readSurfaceID.readSync(surfaceIDTest, {length: 13});
+ let view2 = new Uint8Array(surfaceIDTest);
+ for (let i = 0; i < 13; i++) {
+ let value = view2[i] - 48;
+ surfaceID = surfaceID + '' + value;
+ }
+ console.info('in case surfaceID ' + surfaceID);
+ readSurfaceID.closeSync();
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs(){
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 16.67;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ if (frameCountIn == ES_FRAME_SIZE.length / 2) {
+ videoDecodeProcessor.setParameter({
+ 'bitrate': 6400,
+ }).then(() => {
+ console.info('in case: setParameter success ');
+ }, failCallback).catch(failCatch);
+ }
+ videoDecodeProcessor.queueInput(inputObject).then(() => {
+ console.info('in case: queueInput success ');
+ }, failCallback).catch(failCatch);
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep){
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1) {
+ nextStep();
+ return;
+ }
+ frameCountOut++;
+ await videoDecodeProcessor.releaseOutput(outputObject, true).then(() => {
+ console.log('in case: release output count:' + frameCountOut);
+ }, failCallback).catch(failCatch);
+ }
+ }
+
+ function setCallback(nextStep){
+ console.info('in case: setCallback in');
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ videoDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
+ console.info('get outputMediaDescription : ' + MediaDescription);
+ }, failCallback).catch(failCatch);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ console.info('in case: setCallback out');
+ }
+
+ async function toCreateVideoDecoderByMime(mime, done) {
+ await media.createVideoDecoderByMime(mime).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoDecodeProcessor = processor;
+ console.info('in case : createVideoDecoderByMime success');
+ } else {
+ console.info('in case : createVideoDecoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ }
+ async function toGetVideoDecoderCaps() {
+ await videoDecodeProcessor.getVideoDecoderCaps().then((videoCaps) => {
+ console.info("case get getVideoDecoderCaps 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}]
+ `);
+ }, failCallback).catch(failCatch);
+ }
+ async function toConfigure(mediaDescription, srcPath) {
+ await videoDecodeProcessor.configure(mediaDescription).then(() =>{
+ console.info('in case : configure success');
+ readFile(srcPath);
+ }, failCallback).catch(failCatch);
+ }
+ async function toSetOutputSurface(isDisplay) {
+ await videoDecodeProcessor.setOutputSurface(surfaceID, isDisplay).then(() => {
+ console.info('in case : setOutputSurface success. surfaceID ' + surfaceID);
+ }, failCallback).catch(failCatch);
+ }
+ eventEmitter.on('nextStep', async (done) => {
+ console.info('in case : nextStep success');
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('in case : stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('in case : reset success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ console.info('in case : done');
+ done();
+ });
+ async function toPrepare() {
+ await videoDecodeProcessor.prepare().then(() => {
+ console.info('in case : prepare success');
+ }, failCallback).catch(failCatch);
+ }
+ async function toStart() {
+ await videoDecodeProcessor.start().then(() => {
+ console.info('in case : start success');
+ }, failCallback).catch(failCatch);
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_H264_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_H264_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 4,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByMime('video/avc', done);
+ await toGetVideoDecoderCaps();
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_H263_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_H263_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H263_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'h263_1408_1152.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/h263',
+ 'width': 1408,
+ 'height': 1152,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByMime('video/h263', done);
+ await toGetVideoDecoderCaps();
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_MPEG2_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_MPEG2_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG2_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'MPEG2_720_480.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mpeg2',
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByMime('video/mpeg2', done);
+ await toGetVideoDecoderCaps();
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_MPEG4_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_MPEG4_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG4_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'mpeg4_320_240.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mp4v-es',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 4,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByMime('video/mp4v-es', done);
+ await toGetVideoDecoderCaps();
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_MULTIINSTANCE_PROMISE_0100
+ * @tc.name : 001.creat 16 video decoder
+ * @tc.desc : creat 16 video decoder
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_MULTIINSTANCE_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 4,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ let array = new Array();
+ eventEmitter.on('releaseAllDecoder', async () => {
+ for (let j = 0; j < 15; j++) {
+ await array[j].release().then(() => {
+ array[j] = null;
+ }, failCallback).catch(failCatch);
+ }
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ done();
+ })
+ for (let i = 0; i < 16; i++) {
+ await media.createVideoDecoderByMime('video/avc').then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ console.info('in case : createVideoDecoderByMime success');
+ if (i == 15) {
+ videoDecodeProcessor = processor;
+ } else {
+ array[i] = processor;
+ }
+ } else {
+ console.info('in case : createVideoDecoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ }
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('releaseAllDecoder', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f5cbc5228a6ffa1e1cd8cb53c5dfe7d75b271ad1
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
@@ -0,0 +1,1279 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+export
+const DECODE_STEP = {
+ WAIT_FOR_EOS : 'waitForEOS',
+ CONFIGURE : 'configure',
+ SETSURFACE : 'setSurface',
+ PREPARE : 'prepare',
+ START : 'start',
+ FLUSH : 'flush',
+ STOP : 'stop',
+ RESET : 'reset',
+ WAIT_FOR_ALL_OUTS : 'waitForAllOuts',
+ ERROR : 'error',
+ RELEASE : 'release',
+}
+
+describe('VideoDecoderReliCallbackTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let position = 0;
+ let eosFrameId = -1;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = true;
+ let inputEosFlag = false;
+ let workdoneAtEOS = false;
+ let surfaceID = '';
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 4,
+ 'frame_rate': 30,
+ 'max_input_size': 150000,
+ }
+
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ workdoneAtEOS = false;
+ eosFrameId = -1;
+ inputEosFlag = false;
+ position = 0;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+ let failCatch = function(err) {
+ console.info(`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.info('in case error failCatch called,err is ' + err);
+ console.info(`in case error failCatch called,errMessage is ${err.message}`);
+ }
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: file path ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, pos, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ if (pos == -1) {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ });
+ } else {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ position: pos,
+ });
+ }
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent err ' + err);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs() {
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ position = position + ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 1000 / mediaDescription.frame_rate;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject, (err) => {
+ console.info('in case: queueInput success ');
+ })
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep) {
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ if (workdoneAtEOS) {
+ doneWork(nextStep);
+ }
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true, () => {
+ console.log('in case: release output count:' + frameCountOut);
+ })
+ }
+ }
+
+ function toConfigure(mySteps, done, expectFail) {
+ videoDecodeProcessor.configure(mediaDescription, (err) => {
+ console.info(`case configure callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toPrepare(mySteps, done, expectFail) {
+ videoDecodeProcessor.prepare((err) => {
+ console.info(`case prepare callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toStart(mySteps, done, expectFail) {
+ let timeDelay = 0;
+ videoDecodeProcessor.start((err) => {
+ console.info(`case start callback`);
+ printError(err, expectFail);
+ if (mySteps[0] == DECODE_STEP.FLUSH) {
+ timeDelay = 500;
+ }
+ setTimeout(() => {
+ toNextStep(mySteps, done);
+ }, timeDelay);
+ });
+ }
+ function toFlush(mySteps, done, expectFail) {
+ videoDecodeProcessor.flush((err) => {
+ console.info(`case flush callback`);
+ printError(err, expectFail);
+ if (expectFail == false) {
+ inputEosFlag = false;
+ position = ES_FRAME_SIZE[0];
+ inputQueue = [];
+ timestamp = 0;
+ frameCountIn = 1;
+ }
+ toNextStep(mySteps, done);
+ });
+ }
+ function toStop(mySteps, done, expectFail) {
+ videoDecodeProcessor.stop((err) => {
+ console.info(`case stop callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toReset(mySteps, done, expectFail) {
+ videoDecodeProcessor.reset((err) => {
+ console.info(`case reset callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toSetOutputSurface(mySteps, done, expectFail) {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true, (err) => {
+ console.info('case setOutputSurface callback, surfaceID ' + surfaceID);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toNextStep(mySteps, done) {
+ console.info('case myStep[0]: ' + mySteps[0]);
+ if (mySteps[0] == DECODE_STEP.RELEASE) {
+ if (videoDecodeProcessor != null){
+ videoDecodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('in case : videoDecodeProcessor release callback');
+ videoDecodeProcessor = null;
+ console.info('case to done');
+ done();
+ });
+ }
+ return;
+ }
+ switch (mySteps[0]) {
+ case DECODE_STEP.CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toConfigure(mySteps, done, true);
+ } else {
+ toConfigure(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.SETSURFACE:
+ mySteps.shift();
+ console.info(`case to setOutputSurface`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toSetOutputSurface(mySteps, done, true);
+ } else {
+ toSetOutputSurface(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toPrepare(mySteps, done, true);
+ } else {
+ toPrepare(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.START:
+ mySteps.shift();
+ console.info(`case to start`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStart(mySteps, done, true);
+ } else {
+ readStreamSync = undefined;
+ readFile(SRCPATH);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ position = 0;
+ toStart(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toFlush(mySteps, done, true);
+ } else {
+ toFlush(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStop(mySteps, done, true);
+ } else {
+ toStop(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toReset(mySteps, done, true);
+ } else {
+ toReset(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.WAIT_FOR_EOS:
+ mySteps.shift();
+ setTimeout(() =>{
+ expect(inputEosFlag).assertTrue();
+ if (inputEosFlag == false) {
+ console.info(`in case error wait for eos: inputEosFlag = false`);
+ }
+ toNextStep(mySteps, done);
+ }, 7000); // wait 7000 ms for eos
+ break;
+ case DECODE_STEP.WAIT_FOR_ALL_OUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function setCallback(nextStep){
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ }
+
+ function toCreateVideoDecoderByMime(mime, mySteps, done) {
+ media.createVideoDecoderByMime(mime, (err, processor) => {
+ console.info(`case createVideoDecoderByMime callback`);
+ printError(err, false);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toCreateVideoDecoderByName(name, mySteps, done) {
+ media.createVideoDecoderByName(name, (err, processor) => {
+ printError(err, false);
+ console.info(`case createVideoDecoderByName callback`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ })
+ }
+ async function doneWork(nextStep) {
+ videoDecodeProcessor.stop((err) => {
+ printError(err, false);
+ console.info('case stop callback');
+ videoDecodeProcessor.reset((err) => {
+ printError(err, false);
+ console.info('case reset callback');
+ videoDecodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('case release callback');
+ videoDecodeProcessor = null;
+ nextStep();
+ })
+ })
+ })
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0100
+ * @tc.name : test set EOS manually before last frame and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0200
+ * @tc.name : test flush at running state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0300
+ * @tc.name : test flush at EOS state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ eosFrameId = 50;
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0400
+ * @tc.name : test stop at running state and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0500
+ * @tc.name : test stop and restart
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0900', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS ,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_PREPARE_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.START,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_START_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.FLUSH,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP , DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_FLUSH_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.STOP,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_STOP_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.RESET,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_RESET_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_EOS_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_EOS_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_EOS_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_EOS_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_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_DECODER_API_EOS_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..82825c3f64ca89a5d9ccc72e5c6b48c2eab2dbc9
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
@@ -0,0 +1,1269 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+export
+const DECODE_STEP = {
+ WAIT_FOR_EOS : 'waitForEOS',
+ CONFIGURE : 'configure',
+ SETSURFACE : 'setSurface',
+ PREPARE : 'prepare',
+ START : 'start',
+ FLUSH : 'flush',
+ STOP : 'stop',
+ RESET : 'reset',
+ WAIT_FOR_ALL_OUTS : 'waitForAllOuts',
+ ERROR : 'error',
+ RELEASE : 'release',
+}
+
+describe('VideoDecoderReliPromiseTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let position = 0;
+ let eosFrameId = -1;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = true;
+ let inputEosFlag = false;
+ let workdoneAtEOS = false;
+ let surfaceID = '';
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 4,
+ 'frame_rate': 30,
+ 'max_input_size': 150000,
+ }
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ workdoneAtEOS = false;
+ eosFrameId = -1;
+ inputEosFlag = false;
+ position = 0;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let caseCallback = function(err) {
+ console.info(`in case caseCallback called, caseMessage is ${err.message}`);
+ }
+ 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();
+ }
+ let callbackExpectOK = function(err, mySteps, done) {
+ console.error(`in case error callbackExpectOK called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ toNextStep(mySteps, done);
+ }
+ let callbackExpectFail = function(err, mySteps, done) {
+ console.info(`in case callbackExpectFail called, errMessage is ${err.message}`);
+ expect(err != undefined).assertTrue();
+ toNextStep(mySteps, done);
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: file path ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, pos, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ if (pos == -1) {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ });
+ } else {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ position: pos,
+ });
+ }
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent err ' + err);
+ }
+ }
+ /* push inputbuffers into codec */
+ async function enqueueInputs() {
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ position = position + ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 1000 / mediaDescription.frame_rate;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject).then(() => {
+ console.info('in case: queueInput success ');
+ }, caseCallback).catch(failCatch);
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep) {
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ if (workdoneAtEOS) {
+ await doneWork();
+ nextStep();
+ }
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true).then(() => {
+ console.info('in case: release output success');
+ console.log('in case: release output count:' + frameCountOut);
+ }, caseCallback).catch(failCatch);
+ }
+ }
+
+ function toConfigure(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.configure(mediaDescription).then(() => {
+ console.info(`case configure success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toPrepare(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.prepare().then(() => {
+ console.info(`case prepare success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toStart(mySteps, done, failureCallback, catchCallback) {
+ let timeDelay = 0;
+ videoDecodeProcessor.start().then(() => {
+ console.info(`case start success`);
+ if (mySteps[0] == DECODE_STEP.FLUSH) {
+ timeDelay = 500;
+ }
+ setTimeout(() => {
+ toNextStep(mySteps, done);
+ }, timeDelay);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toFlush(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.flush().then(() => {
+ console.info(`case flush success`);
+ position = ES_FRAME_SIZE[0];
+ inputQueue = [];
+ timestamp = 0;
+ inputEosFlag = false;
+ frameCountIn = 1;
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toStop(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.stop().then(() => {
+ console.info(`case stop success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toReset(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.reset().then(() => {
+ console.info(`case reset success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toSetOutputSurface(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true).then(() => {
+ console.info('in case : setOutputSurface success, surfaceID ' + surfaceID);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toNextStep(mySteps, done) {
+ console.info('case myStep[0]: ' + mySteps[0]);
+ if (mySteps[0] == DECODE_STEP.RELEASE) {
+ if (videoDecodeProcessor != null) {
+ videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ videoDecodeProcessor = null;
+ console.info('case to done');
+ done();
+ }, failCallback).catch(failCatch);
+ }
+ return;
+ }
+ switch (mySteps[0]) {
+ case DECODE_STEP.CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toConfigure(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toConfigure(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.SETSURFACE:
+ mySteps.shift();
+ console.info(`case to setOutputSurface`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toSetOutputSurface(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toSetOutputSurface(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toPrepare(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toPrepare(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.START:
+ mySteps.shift();
+ console.info(`case to start`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStart(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ readStreamSync = undefined;
+ readFile(SRCPATH);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ position = 0;
+ toStart(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toFlush(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toFlush(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStop(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toStop(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toReset(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toReset(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.WAIT_FOR_EOS:
+ mySteps.shift();
+ setTimeout(() =>{
+ expect(inputEosFlag).assertTrue();
+ if (inputEosFlag == false) {
+ console.info(`in case error inputEosFlag == false`);
+ }
+ toNextStep(mySteps, done);
+ }, 7000); // wait 7000 ms for eos
+ break;
+ case DECODE_STEP.WAIT_FOR_ALL_OUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function setCallback(nextStep){
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged', (format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ }
+
+ function toCreateVideoDecoderByMime(mime, mySteps, done) {
+ media.createVideoDecoderByMime(mime).then((processor) => {
+ console.info(`case createVideoDecoderByMime success`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ }, failCallback).catch(failCatch);
+ }
+ function toCreateVideoDecoderByName(name, mySteps, done) {
+ media.createVideoDecoderByName(name).then((processor) => {
+ console.info(`case createVideoDecoderByName success`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ }, failCallback).catch(failCatch);
+ }
+ async function doneWork() {
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('case stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('case reset success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.release().then(() => {
+ console.info('case release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0100
+ * @tc.name : test set EOS manually before last frame and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0200
+ * @tc.name : test flush at running state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0300
+ * @tc.name : test flush at EOS state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ eosFrameId = 50;
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0400
+ * @tc.name : test stop at running state and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0500
+ * @tc.name : test stop and restart
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_PROMISE_01_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0900', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS ,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.START,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.FLUSH,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP , DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.STOP,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.RESET,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByMime('video/avc', mySteps, done);
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4f6762748a3f29112198ab09e4847f7eb2787a57
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
@@ -0,0 +1,590 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('VideoDecoderFuncCallbackTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = false;
+ let inputEosFlag = false;
+ let surfaceID = '';
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ let ES_FRAME_SIZE = [];
+ const H264_FRAME_SIZE_240 =
+ [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97,
+ 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132,
+ 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230,
+ 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140,
+ 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179,
+ 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122,
+ 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162,
+ 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149,
+ 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162,
+ 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147,
+ 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144,
+ 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613,
+ 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049,
+ 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140,
+ 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124,
+ 2049, 180, 122, 128, 1334, 143, 128, 1379, 116, 1884, 149, 122, 150, 1962, 176, 122, 122, 1197, 139,
+ 1853, 184, 151, 148, 1692, 209, 129, 126, 1736, 149, 135, 104, 1775, 165, 160, 121, 1653, 163, 123,
+ 112, 1907, 181, 129, 107, 1808, 177, 125, 111, 2405, 166, 144, 114, 1833, 198, 136, 113, 1960, 206,
+ 139, 116, 1791, 175, 130, 129, 1909, 194, 138, 119, 1807, 160, 156, 124, 1998, 184, 173, 114, 2069, 181,
+ 127, 139, 2212, 182, 138, 146, 1993, 214, 135, 139, 2286, 194, 137, 120, 2090, 196, 159, 132, 2294, 194,
+ 148, 137, 2312, 183, 163, 106, 2118, 201, 158, 127, 2291, 187, 144, 116, 2413, 139, 115, 2148, 178, 122,
+ 103, 2370, 207, 161, 117, 2291, 213, 159, 129, 2244, 243, 157, 133, 2418, 255, 171, 127, 2316, 185, 160,
+ 132, 2405, 220, 165, 155, 2539, 219, 172, 128, 2433, 199, 154, 119, 1681, 140, 1960, 143, 2682, 202, 153,
+ 127, 2794, 239, 158, 155, 2643, 229, 172, 125, 2526, 201, 181, 159, 2554, 233, 167, 125, 2809, 205, 164,
+ 117, 2707, 221, 156, 138, 2922, 240, 160, 146, 2952, 267, 177, 149, 3339, 271, 175, 136, 3006, 242, 168,
+ 141, 3068, 232, 194, 149, 2760, 214, 208, 143, 2811, 218, 184, 149, 137, 15486, 2116, 235, 167, 157, 2894,
+ 305, 184, 139, 3090, 345, 179, 155, 3226, 347, 160, 164, 3275, 321, 184, 174, 3240, 269, 166, 170, 3773,
+ 265, 169, 155, 3023, 301, 188, 161, 3343, 275, 174, 155, 3526, 309, 177, 173, 3546, 307, 183, 149, 3648,
+ 295, 213, 170, 3568, 305, 198, 166, 3641, 297, 172, 148, 3608, 301, 200, 159, 3693, 322, 209, 166, 3453,
+ 318, 206, 162, 3696, 341, 200, 176, 3386, 320, 192, 176, 3903, 373, 207, 187, 3305, 361, 200, 202, 3110,
+ 367, 220, 197, 2357, 332, 196, 201, 1827, 377, 187, 199, 860, 472, 173, 223, 238];
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ const H263_FRAME_SIZE =
+ [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244,
+ 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165,
+ 24267, 36171, 18330, 53228, 7893, 13088, 9502, 8485, 9207, 8681, 9202, 8537, 7603, 9726, 8191, 51872,
+ 5535, 6146, 6341, 6933, 9365, 7828, 6547, 7638, 7009, 7025, 8873, 51045, 5056, 4858, 4887, 9614, 5953,
+ 5972, 6116, 6060, 6296, 6239, 6400, 50928, 4937, 5054, 5371, 6728, 6286, 6524, 6646, 6549, 6036, 6214,
+ 5866, 51109, 4778, 5273, 6327];
+ const MPEG2_FRAME_SIZE =
+ [ 38462, 55096, 8660, 3417, 1197, 2209, 984, 718, 783, 623, 659, 694, 14174, 580, 421, 495, 480, 476, 534,
+ 660, 699, 601, 603, 720, 12585, 555, 532, 776, 789, 762, 766, 732, 671, 735, 777, 948, 12650, 827, 766,
+ 835, 747, 847, 940, 1121, 1092, 1001, 980, 989, 12746, 945, 912, 1046, 1118, 1134, 1050, 1073, 1051, 1195,
+ 1085, 1182, 12874, 992, 1007, 985, 1040, 1143, 1157, 1150, 1247, 1149, 1246, 1145, 12870, 1041, 1066, 1314,
+ 1239, 1283, 1223, 1224, 1270, 1427, 1406, 1516, 12949, 1228, 1299, 1439, 1358, 1455, 1311, 1396, 1416, 1470,
+ 1393, 1502, 12999, 1232, 1400, 1348, 1335, 1461, 1404, 1412, 1426, 1548, 1481, 1488, 12840, 1229, 1342, 1323,
+ 1353, 1524, 1363, 1475, 1540, 1495, 1489, 1438, 12762, 1291, 1303, 1470, 1494, 1488, 1474, 1453, 1607, 1485,
+ 1589, 1762, 12548, 1363, 1317, 1435, 1411, 1338, 1373, 1605, 1639, 1429, 1392, 1543, 12332, 1255, 1200, 1291,
+ 1337, 1341, 1356, 1214, 1456, 1353, 1314, 1502, 12151, 1192, 1290, 1203, 1284, 1154, 1264, 1358, 1390, 1433,
+ 1194, 1325, 11904, 993, 1007, 1149, 1099, 1182, 1076, 1074, 1092, 1030, 1272, 1178, 11710, 966, 879, 860, 955,
+ 898, 967, 927, 1066, 997, 1083, 940, 11717, 648, 705, 901, 925, 930, 868, 798, 846, 781, 825, 1027, 11587, 785,
+ 733, 731, 848, 753, 806, 699, 837, 750, 762, 748, 11541, 678, 742, 667, 735, 702, 837, 695, 773, 849, 869, 769,
+ 11381, 664, 705, 714, 698, 814, 846, 757, 802, 857, 905, 772, 11265, 718, 643, 597, 687, 774, 843, 747, 785,
+ 683, 1135, 676, 11259, 616, 595, 773, 746, 798, 722, 798, 790, 959, 771, 907, 11234, 705, 675, 773, 764, 846,
+ 789, 840, 853, 828, 774, 842, 11263, 758, 758, 757, 820, 847, 834, 884, 842, 988, 750, 952, 11236, 776, 640, 727,
+ 832, 855, 733, 822, 827, 862, 697, 924, 11176, 675, 615, 688, 818, 783, 746, 901, 834, 892, 759, 923, 11181, 661,
+ 578, 720, 697];
+ const MPEG4_FRAME_SIZE =
+ [ 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959,
+ 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451,
+ 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317,
+ 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401,
+ 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423,
+ 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439,
+ 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268,
+ 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334,
+ 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287,
+ 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302,
+ 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259,
+ 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433,
+ 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287,
+ 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235,
+ 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228,
+ 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719];
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = false;
+ inputEosFlag = false;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ let failCatch = function(err) {
+ console.info(`in case error failCatch called,errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: filepath ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case error readFile' + e);
+ }
+ }
+ function getContent(buf, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ lengthReal = readStreamSync.readSync(
+ buf,
+ {length: len}
+ );
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent: ' + e);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs(){
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 16.67;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject, (err) => {
+ if (typeof (err) == 'undefined') {
+ console.info('in case: queueInput success ');
+
+ } else {
+ console.info(`in case queueInput err called,errMessage is ${error.message}`);
+ }
+ })
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep){
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ nextStep();
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true, (err) => {
+ if (typeof (err) == 'undefined') {
+ console.log('in case: release output count:' + frameCountOut);
+ } else {
+ console.info(`in case releaseOutput error called,errMessage is ${error.message}`);
+ }
+ })
+ }
+ }
+
+ function setCallback(nextStep){
+ console.info('in case: setCallback in');
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ console.info('in case: setCallback out');
+ }
+ eventEmitter.on('configure', (mediaDescription, srcPath, nextStep, done) => {
+ console.info('in case : configure in');
+ videoDecodeProcessor.configure(mediaDescription, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : configure success');
+ readFile(srcPath);
+ setCallback(nextStep);
+ eventEmitter.emit('setOutputSurface', done);
+ });
+ });
+ eventEmitter.on('setOutputSurface', (done) => {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true, (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : setOutputSurface success, surfaceID ' + surfaceID);
+ eventEmitter.emit('prepare', done);
+ })
+ });
+ eventEmitter.on('prepare', (done) => {
+ videoDecodeProcessor.prepare((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : prepare success');
+ eventEmitter.emit('start', done);
+ });
+ });
+ eventEmitter.on('start', (done) => {
+ videoDecodeProcessor.start((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : start success');
+ });
+ });
+ eventEmitter.on('stop', (done) => {
+ videoDecodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : stop success');
+ eventEmitter.emit('reset', done);
+ });
+ });
+ eventEmitter.on('reset', (done) => {
+ videoDecodeProcessor.reset((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset success');
+ eventEmitter.emit('release', done);
+ });
+ });
+ eventEmitter.on('release', (done) => {
+ videoDecodeProcessor.release((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : release success');
+ videoDecodeProcessor = null;
+ done();
+ });
+ });
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByName('avdec_h264', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H263_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'h263_1408_1152.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/h263',
+ 'width': 1408,
+ 'height': 1152,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByName('avdec_h263', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG2_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG2_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG2_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'MPEG2_720_480.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mpeg2',
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByName('avdec_mpeg2video', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG4_CALLBACK_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG4_CALLBACK_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG4_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'mpeg4_320_240.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mp4v-es',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ media.createVideoDecoderByName('avdec_mpeg4', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0600
+ * @tc.name : test reconfigure for new file with the same format
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0600', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ eventEmitter.on('stop_for_callback_01_0600', (done) => {
+ videoDecodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : stop_for_callback_01_0600 success');
+ eventEmitter.emit('reset_for_callback_01_0600', done);
+ });
+ });
+ eventEmitter.on('reset_for_callback_01_0600', (done) => {
+ videoDecodeProcessor.reset(async (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset_for_callback_01_0600 success');
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ readStreamSync = null;
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ surfaceID = globalThis.value;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ });
+ media.createVideoDecoderByName('avdec_h264', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop_for_callback_01_0600', done);
+ }, done);
+ });
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0700
+ * @tc.name : test reconfigure for new file with the different format
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0700', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ eventEmitter.on('stop_for_callback_01_0700', (done) => {
+ videoDecodeProcessor.stop((err) => {
+ expect(err).assertUndefined();
+ console.info('in case : stop_for_callback_01_0700 success');
+ eventEmitter.emit('reset_for_callback_01_0700', done);
+ });
+ });
+ eventEmitter.on('reset_for_callback_01_0700', (done) => {
+ videoDecodeProcessor.reset(async (err) => {
+ expect(err).assertUndefined();
+ console.info('in case : reset_for_callback_01_0700 success');
+ srcPath = BASIC_PATH + 'out_320_240_10s.h264';
+ mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ readStreamSync = null;
+ ES_FRAME_SIZE = H264_FRAME_SIZE_240;
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ surfaceID = globalThis.value;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop', done);
+ }, done);
+ });
+ });
+ media.createVideoDecoderByName('avdec_h264', (err, processor) => {
+ expect(err).assertUndefined();
+ console.info('in case : createVideoDecoderByName success');
+ videoDecodeProcessor = processor;
+ eventEmitter.emit('configure', mediaDescription, srcPath,
+ function() {
+ eventEmitter.emit('stop_for_callback_01_0700', done);
+ }, done);
+ });
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..14fc597ad65fc677d00de659fd0ba85243d8986b
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
@@ -0,0 +1,584 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+
+describe('VideoDecoderFuncPromiseTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = false;
+ let inputEosFlag = false;
+ let surfaceID = '';
+ const events = require('events');
+ const eventEmitter = new events.EventEmitter();
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ let ES_FRAME_SIZE = [];
+ const H264_FRAME_SIZE_240 =
+ [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97,
+ 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132,
+ 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230,
+ 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140,
+ 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179,
+ 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122,
+ 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162,
+ 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149,
+ 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162,
+ 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147,
+ 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144,
+ 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613,
+ 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049,
+ 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140,
+ 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124,
+ 2049, 180, 122, 128, 1334, 143, 128, 1379, 116, 1884, 149, 122, 150, 1962, 176, 122, 122, 1197, 139,
+ 1853, 184, 151, 148, 1692, 209, 129, 126, 1736, 149, 135, 104, 1775, 165, 160, 121, 1653, 163, 123,
+ 112, 1907, 181, 129, 107, 1808, 177, 125, 111, 2405, 166, 144, 114, 1833, 198, 136, 113, 1960, 206,
+ 139, 116, 1791, 175, 130, 129, 1909, 194, 138, 119, 1807, 160, 156, 124, 1998, 184, 173, 114, 2069, 181,
+ 127, 139, 2212, 182, 138, 146, 1993, 214, 135, 139, 2286, 194, 137, 120, 2090, 196, 159, 132, 2294, 194,
+ 148, 137, 2312, 183, 163, 106, 2118, 201, 158, 127, 2291, 187, 144, 116, 2413, 139, 115, 2148, 178, 122,
+ 103, 2370, 207, 161, 117, 2291, 213, 159, 129, 2244, 243, 157, 133, 2418, 255, 171, 127, 2316, 185, 160,
+ 132, 2405, 220, 165, 155, 2539, 219, 172, 128, 2433, 199, 154, 119, 1681, 140, 1960, 143, 2682, 202, 153,
+ 127, 2794, 239, 158, 155, 2643, 229, 172, 125, 2526, 201, 181, 159, 2554, 233, 167, 125, 2809, 205, 164,
+ 117, 2707, 221, 156, 138, 2922, 240, 160, 146, 2952, 267, 177, 149, 3339, 271, 175, 136, 3006, 242, 168,
+ 141, 3068, 232, 194, 149, 2760, 214, 208, 143, 2811, 218, 184, 149, 137, 15486, 2116, 235, 167, 157, 2894,
+ 305, 184, 139, 3090, 345, 179, 155, 3226, 347, 160, 164, 3275, 321, 184, 174, 3240, 269, 166, 170, 3773,
+ 265, 169, 155, 3023, 301, 188, 161, 3343, 275, 174, 155, 3526, 309, 177, 173, 3546, 307, 183, 149, 3648,
+ 295, 213, 170, 3568, 305, 198, 166, 3641, 297, 172, 148, 3608, 301, 200, 159, 3693, 322, 209, 166, 3453,
+ 318, 206, 162, 3696, 341, 200, 176, 3386, 320, 192, 176, 3903, 373, 207, 187, 3305, 361, 200, 202, 3110,
+ 367, 220, 197, 2357, 332, 196, 201, 1827, 377, 187, 199, 860, 472, 173, 223, 238];
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ const H263_FRAME_SIZE =
+ [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244,
+ 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165,
+ 24267, 36171, 18330, 53228, 7893, 13088, 9502, 8485, 9207, 8681, 9202, 8537, 7603, 9726, 8191, 51872,
+ 5535, 6146, 6341, 6933, 9365, 7828, 6547, 7638, 7009, 7025, 8873, 51045, 5056, 4858, 4887, 9614, 5953,
+ 5972, 6116, 6060, 6296, 6239, 6400, 50928, 4937, 5054, 5371, 6728, 6286, 6524, 6646, 6549, 6036, 6214,
+ 5866, 51109, 4778, 5273, 6327];
+ const MPEG2_FRAME_SIZE =
+ [ 38462, 55096, 8660, 3417, 1197, 2209, 984, 718, 783, 623, 659, 694, 14174, 580, 421, 495, 480, 476, 534,
+ 660, 699, 601, 603, 720, 12585, 555, 532, 776, 789, 762, 766, 732, 671, 735, 777, 948, 12650, 827, 766,
+ 835, 747, 847, 940, 1121, 1092, 1001, 980, 989, 12746, 945, 912, 1046, 1118, 1134, 1050, 1073, 1051, 1195,
+ 1085, 1182, 12874, 992, 1007, 985, 1040, 1143, 1157, 1150, 1247, 1149, 1246, 1145, 12870, 1041, 1066, 1314,
+ 1239, 1283, 1223, 1224, 1270, 1427, 1406, 1516, 12949, 1228, 1299, 1439, 1358, 1455, 1311, 1396, 1416, 1470,
+ 1393, 1502, 12999, 1232, 1400, 1348, 1335, 1461, 1404, 1412, 1426, 1548, 1481, 1488, 12840, 1229, 1342, 1323,
+ 1353, 1524, 1363, 1475, 1540, 1495, 1489, 1438, 12762, 1291, 1303, 1470, 1494, 1488, 1474, 1453, 1607, 1485,
+ 1589, 1762, 12548, 1363, 1317, 1435, 1411, 1338, 1373, 1605, 1639, 1429, 1392, 1543, 12332, 1255, 1200, 1291,
+ 1337, 1341, 1356, 1214, 1456, 1353, 1314, 1502, 12151, 1192, 1290, 1203, 1284, 1154, 1264, 1358, 1390, 1433,
+ 1194, 1325, 11904, 993, 1007, 1149, 1099, 1182, 1076, 1074, 1092, 1030, 1272, 1178, 11710, 966, 879, 860, 955,
+ 898, 967, 927, 1066, 997, 1083, 940, 11717, 648, 705, 901, 925, 930, 868, 798, 846, 781, 825, 1027, 11587, 785,
+ 733, 731, 848, 753, 806, 699, 837, 750, 762, 748, 11541, 678, 742, 667, 735, 702, 837, 695, 773, 849, 869, 769,
+ 11381, 664, 705, 714, 698, 814, 846, 757, 802, 857, 905, 772, 11265, 718, 643, 597, 687, 774, 843, 747, 785,
+ 683, 1135, 676, 11259, 616, 595, 773, 746, 798, 722, 798, 790, 959, 771, 907, 11234, 705, 675, 773, 764, 846,
+ 789, 840, 853, 828, 774, 842, 11263, 758, 758, 757, 820, 847, 834, 884, 842, 988, 750, 952, 11236, 776, 640, 727,
+ 832, 855, 733, 822, 827, 862, 697, 924, 11176, 675, 615, 688, 818, 783, 746, 901, 834, 892, 759, 923, 11181, 661,
+ 578, 720, 697];
+ const MPEG4_FRAME_SIZE =
+ [ 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959,
+ 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451,
+ 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317,
+ 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401,
+ 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423,
+ 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439,
+ 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268,
+ 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334,
+ 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287,
+ 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302,
+ 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259,
+ 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433,
+ 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287,
+ 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235,
+ 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228,
+ 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719];
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = false;
+ inputEosFlag = false;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ let failCatch = function(err) {
+ console.info(`in case error failCatch called,errMessage is ${error.message}`);
+ expect(err).assertUndefined();
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: filepath ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.error('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ lengthReal = readStreamSync.readSync(
+ buf,
+ {length: len}
+ );
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent ' + e);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs(){
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 16.67;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject).then(() => {
+ console.info('in case: queueInput success ');
+ }, failCallback).catch(failCatch);
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep){
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1) {
+ nextStep();
+ return;
+ }
+ frameCountOut++;
+ await videoDecodeProcessor.releaseOutput(outputObject, true).then(() => {
+ console.log('in case: release output count:' + frameCountOut);
+ }, failCallback).catch(failCatch);
+ }
+ }
+
+ function setCallback(nextStep){
+ console.info('in case: setCallback in');
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ console.info('in case: setCallback out');
+ }
+
+ async function toCreateVideoDecoderByMime(mime, done) {
+ await media.createVideoDecoderByMime(mime).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoDecodeProcessor = processor;
+ console.info('in case : createVideoDecoderByMime success');
+ } else {
+ console.info('in case : createVideoDecoderByMime fail');
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ }
+ async function toCreateVideoDecoderByName(name, done) {
+ await media.createVideoDecoderByName(name).then((processor) => {
+ if (typeof (processor) != 'undefined') {
+ videoDecodeProcessor = processor;
+ console.info('in case : createVideoDecoderByName success');
+ } else {
+ console.info('in case : createVideoDecoderByName fail');
+ expect().assertFail();
+ done();
+ }
+ }, failCallback).catch(failCatch);
+ }
+ async function toConfigure(mediaDescription, srcPath) {
+ await videoDecodeProcessor.configure(mediaDescription).then(() =>{
+ console.info('in case : configure success');
+ readFile(srcPath);
+ }, failCallback).catch(failCatch);
+ }
+ async function toSetOutputSurface(isDisplay) {
+ await videoDecodeProcessor.setOutputSurface(surfaceID, isDisplay).then(() => {
+ console.info('in case : setOutputSurface success. surfaceID ' + surfaceID);
+ }, failCallback).catch(failCatch);
+ }
+ eventEmitter.on('nextStep', async (done) => {
+ console.info('in case : nextStep success');
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('in case : stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('in case : reset success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ console.info('in case : done');
+ done();
+ });
+ async function toPrepare() {
+ await videoDecodeProcessor.prepare().then(() => {
+ console.info('in case : prepare success');
+ }, failCallback).catch(failCatch);
+ }
+ async function toStart() {
+ await videoDecodeProcessor.start().then(() => {
+ console.info('in case : start success');
+ }, failCallback).catch(failCatch);
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_h264', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = H263_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'h263_1408_1152.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/h263',
+ 'width': 1408,
+ 'height': 1152,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_h263', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG2_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG2_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG2_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'MPEG2_720_480.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mpeg2',
+ 'width': 720,
+ 'height': 480,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_mpeg2video', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG4_PROMISE_0100
+ * @tc.name : 001.basic Video decode function
+ * @tc.desc : start-> EOS -> stop -> reset
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_MPEG4_PROMISE_0100', 0, async function (done) {
+ ES_FRAME_SIZE = MPEG4_FRAME_SIZE;
+ let srcPath = BASIC_PATH + 'mpeg4_320_240.es';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/mp4v-es',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_mpeg4', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0600
+ * @tc.name : test reconfigure for new file with the same format
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0600', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_h264', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ eventEmitter.once('reConfigure_for_promise_01_0600', async (done) => {
+ console.info('in case : reConfigure_for_promise_01_0600 success');
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('in case : stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('in case : reset success');
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ readStreamSync = null;
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ surfaceID = globalThis.value;
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ });
+ setCallback(
+ function(){eventEmitter.emit('reConfigure_for_promise_01_0600', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0700
+ * @tc.name : test reconfigure for new file with the different format
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0700', 0, async function (done) {
+ ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ isCodecData = true;
+ let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ await toCreateVideoDecoderByName('avdec_h264', done);
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ srcPath = BASIC_PATH + 'out_320_240_10s.h264';
+ mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 320,
+ 'height': 240,
+ 'pixel_format': 3,
+ 'frame_rate': 60.00,
+ 'max_input_size': 150000,
+ }
+ eventEmitter.on('reConfigure_for_promise_01_0700', async (done) => {
+ console.info('in case : reConfigure_for_promise_01_0700 success');
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('in case : stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('in case : reset success');
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ readStreamSync = null;
+ ES_FRAME_SIZE = H264_FRAME_SIZE_240;
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ surfaceID = globalThis.value;
+ await toConfigure(mediaDescription, srcPath);
+ await toSetOutputSurface(true);
+ setCallback(
+ function(){eventEmitter.emit('nextStep', done);}
+ );
+ await toPrepare();
+ await toStart();
+ });
+ setCallback(
+ function(){eventEmitter.emit('reConfigure_for_promise_01_0700', done);}
+ );
+ await toPrepare();
+ await toStart();
+ })
+})
+
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7d9f7ff9716e963dd46ae3d8aecc21a19400c962
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
@@ -0,0 +1,1280 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+export
+const DECODE_STEP = {
+ WAIT_FOR_EOS : 'waitForEOS',
+ CONFIGURE : 'configure',
+ SETSURFACE : 'setSurface',
+ PREPARE : 'prepare',
+ START : 'start',
+ FLUSH : 'flush',
+ STOP : 'stop',
+ RESET : 'reset',
+ WAIT_FOR_ALL_OUTS : 'waitForAllOuts',
+ ERROR : 'error',
+ RELEASE : 'release',
+}
+
+describe('VideoDecoderSoftwareReliCallbackTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let position = 0;
+ let eosFrameId = -1;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = true;
+ let inputEosFlag = false;
+ let workdoneAtEOS = false;
+ let surfaceID = '';
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30,
+ 'max_input_size': 150000,
+ }
+
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ workdoneAtEOS = false;
+ eosFrameId = -1;
+ inputEosFlag = false;
+ position = 0;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let failCallback = function(err) {
+ console.info(`in case error failCallback called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ }
+ let failCatch = function(err) {
+ console.info(`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.info('in case error failCatch called,err is ' + err);
+ console.info(`in case error failCatch called,errMessage is ${err.message}`);
+ }
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: file path ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, pos, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ if (pos == -1) {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ });
+ } else {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ position: pos,
+ });
+ }
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent err ' + err);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs() {
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ position = position + ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 1000 / mediaDescription.frame_rate;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject, (err) => {
+ console.info('in case: queueInput success ');
+ })
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep) {
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ if (workdoneAtEOS) {
+ doneWork(nextStep);
+ }
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true, () => {
+ console.log('in case: release output count:' + frameCountOut);
+ })
+ }
+ }
+
+ function toConfigure(mySteps, done, expectFail) {
+ videoDecodeProcessor.configure(mediaDescription, (err) => {
+ console.info(`case configure callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toPrepare(mySteps, done, expectFail) {
+ videoDecodeProcessor.prepare((err) => {
+ console.info(`case prepare callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toStart(mySteps, done, expectFail) {
+ let timeDelay = 0;
+ videoDecodeProcessor.start((err) => {
+ console.info(`case start callback`);
+ printError(err, expectFail);
+ if (mySteps[0] == DECODE_STEP.FLUSH) {
+ timeDelay = 500;
+ }
+ setTimeout(() => {
+ toNextStep(mySteps, done);
+ }, timeDelay);
+ });
+ }
+ function toFlush(mySteps, done, expectFail) {
+ videoDecodeProcessor.flush((err) => {
+ console.info(`case flush callback`);
+ printError(err, expectFail);
+ if (expectFail == false) {
+ inputEosFlag = false;
+ position = ES_FRAME_SIZE[0];
+ inputQueue = [];
+ timestamp = 0;
+ frameCountIn = 1;
+ }
+ toNextStep(mySteps, done);
+ });
+ }
+ function toStop(mySteps, done, expectFail) {
+ videoDecodeProcessor.stop((err) => {
+ console.info(`case stop callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toReset(mySteps, done, expectFail) {
+ videoDecodeProcessor.reset((err) => {
+ console.info(`case reset callback`);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+ function toSetOutputSurface(mySteps, done, expectFail) {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true, (err) => {
+ console.info('case setOutputSurface callback, surfaceID ' + surfaceID);
+ printError(err, expectFail);
+ toNextStep(mySteps, done);
+ });
+ }
+
+ function toNextStep(mySteps, done) {
+ console.info('case myStep[0]: ' + mySteps[0]);
+ if (mySteps[0] == DECODE_STEP.RELEASE) {
+ if (videoDecodeProcessor != null){
+ videoDecodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('in case : videoDecodeProcessor release callback');
+ videoDecodeProcessor = null;
+ console.info('case to done');
+ done();
+ });
+ }
+ return;
+ }
+ switch (mySteps[0]) {
+ case DECODE_STEP.CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toConfigure(mySteps, done, true);
+ } else {
+ toConfigure(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.SETSURFACE:
+ mySteps.shift();
+ console.info(`case to setOutputSurface`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toSetOutputSurface(mySteps, done, true);
+ } else {
+ toSetOutputSurface(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toPrepare(mySteps, done, true);
+ } else {
+ toPrepare(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.START:
+ mySteps.shift();
+ console.info(`case to start`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStart(mySteps, done, true);
+ } else {
+ readStreamSync = undefined;
+ readFile(SRCPATH);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ position = 0;
+ toStart(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toFlush(mySteps, done, true);
+ } else {
+ toFlush(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStop(mySteps, done, true);
+ } else {
+ toStop(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toReset(mySteps, done, true);
+ } else {
+ toReset(mySteps, done, false);
+ }
+ break;
+ case DECODE_STEP.WAIT_FOR_EOS:
+ mySteps.shift();
+ setTimeout(() =>{
+ expect(inputEosFlag).assertTrue();
+ if (inputEosFlag == false) {
+ console.info(`in case error wait for eos: inputEosFlag = false`);
+ }
+ toNextStep(mySteps, done);
+ }, 7000); // wait 7000 ms for eos
+ break;
+ case DECODE_STEP.WAIT_FOR_ALL_OUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function setCallback(nextStep){
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged',(format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ }
+
+ function toCreateVideoDecoderByMime(mime, mySteps, done) {
+ media.createVideoDecoderByMime(mime, (err, processor) => {
+ console.info(`case createVideoDecoderByMime callback`);
+ printError(err, false);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ })
+ }
+ function toCreateVideoDecoderByName(name, mySteps, done) {
+ media.createVideoDecoderByName(name, (err, processor) => {
+ printError(err, false);
+ console.info(`case createVideoDecoderByName callback`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ })
+ }
+ async function doneWork(nextStep) {
+ videoDecodeProcessor.stop((err) => {
+ printError(err, false);
+ console.info('case stop callback');
+ videoDecodeProcessor.reset((err) => {
+ printError(err, false);
+ console.info('case reset callback');
+ videoDecodeProcessor.release((err) => {
+ printError(err, false);
+ console.info('case release callback');
+ videoDecodeProcessor = null;
+ nextStep();
+ })
+ })
+ })
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0100
+ * @tc.name : test set EOS manually before last frame and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0200
+ * @tc.name : test flush at running state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0300
+ * @tc.name : test flush at EOS state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ eosFrameId = 50;
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0400
+ * @tc.name : test stop at running state and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0500
+ * @tc.name : test stop and restart
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_CONFIGURE_CALLBACK_0900', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS ,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_PREPARE_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.START,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_START_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.FLUSH,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP , DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_FLUSH_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.STOP,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_STOP_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.RESET,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_RESET_CALLBACK_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_EOS_CALLBACK_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_EOS_CALLBACK_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_EOS_CALLBACK_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_EOS_CALLBACK_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_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_DECODER_API_EOS_CALLBACK_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..693243b8ffc1b28e6702a34042b12ca2ff001cd2
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
@@ -0,0 +1,1271 @@
+/*
+ * 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 media from '@ohos.multimedia.media'
+import Fileio from '@ohos.fileio'
+import router from '@system.router'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+export
+const DECODE_STEP = {
+ WAIT_FOR_EOS : 'waitForEOS',
+ CONFIGURE : 'configure',
+ SETSURFACE : 'setSurface',
+ PREPARE : 'prepare',
+ START : 'start',
+ FLUSH : 'flush',
+ STOP : 'stop',
+ RESET : 'reset',
+ WAIT_FOR_ALL_OUTS : 'waitForAllOuts',
+ ERROR : 'error',
+ RELEASE : 'release',
+}
+
+describe('VideoDecoderSoftwareReliPromiseTest', function () {
+ let videoDecodeProcessor = null;
+ let readStreamSync = undefined;
+ let frameCountIn = 0;
+ let frameCountOut = 0;
+ let timestamp = 0;
+ let position = 0;
+ let eosFrameId = -1;
+ let inputQueue = [];
+ let outputQueue = [];
+ let isCodecData = true;
+ let inputEosFlag = false;
+ let workdoneAtEOS = false;
+ let surfaceID = '';
+ const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/';
+ const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264';
+ let mediaDescription = {
+ 'track_type': 1,
+ 'codec_mime': 'video/avc',
+ 'width': 1920,
+ 'height': 1080,
+ 'pixel_format': 3,
+ 'frame_rate': 30,
+ 'max_input_size': 150000,
+ }
+ const H264_FRAME_SIZE_30FPS_1080 =
+ [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463,
+ 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784,
+ 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935,
+ 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277,
+ 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785,
+ 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937];
+ let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080;
+ beforeAll(function() {
+ console.info('beforeAll case');
+ })
+
+ beforeEach(async function() {
+ console.info('beforeEach case');
+ await toDisplayPage().then(() => {
+ }, failCallback).catch(failCatch);
+ await msleep(1000).then(() => {
+ }, failCallback).catch(failCatch);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ timestamp = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ workdoneAtEOS = false;
+ eosFrameId = -1;
+ inputEosFlag = false;
+ position = 0;
+ surfaceID = globalThis.value;
+ })
+
+ afterEach(async function() {
+ console.info('afterEach case');
+ if (videoDecodeProcessor != null) {
+ await videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+ await router.clear().then(() => {
+ }, failCallback).catch(failCatch);
+ })
+
+ afterAll(function() {
+ console.info('afterAll case');
+ })
+ let caseCallback = function(err) {
+ console.info(`in case caseCallback called, caseMessage is ${err.message}`);
+ }
+ 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();
+ }
+ let callbackExpectOK = function(err, mySteps, done) {
+ console.error(`in case error callbackExpectOK called, errMessage is ${err.message}`);
+ expect(err == undefined).assertTrue();
+ toNextStep(mySteps, done);
+ }
+ let callbackExpectFail = function(err, mySteps, done) {
+ console.info(`in case callbackExpectFail called, errMessage is ${err.message}`);
+ expect(err != undefined).assertTrue();
+ toNextStep(mySteps, done);
+ }
+ function msleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+ }
+ async function toDisplayPage() {
+ let path = 'pages/display/display';
+ let options = {
+ uri: path,
+ }
+ try {
+ await router.push(options);
+ } catch (e) {
+ console.error('in case toDisplayPage' + e);
+ }
+ }
+ function readFile(path){
+ console.info('in case : read file start execution');
+ try {
+ console.info('in case: file path ' + path);
+ readStreamSync = Fileio.createStreamSync(path, 'rb');
+ } catch(e) {
+ console.info('in case readFile' + e);
+ }
+ }
+
+ function getContent(buf, pos, len) {
+ console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength);
+ let lengthReal = -1;
+ try {
+ if (pos == -1) {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ });
+ } else {
+ lengthReal = readStreamSync.readSync(buf, {
+ length: len,
+ position: pos,
+ });
+ }
+ console.info('in case: lengthReal: ' + lengthReal);
+ } catch(e) {
+ console.error('in case error getContent err ' + err);
+ }
+ }
+
+ /* push inputbuffers into codec */
+ async function enqueueInputs() {
+ console.info('in case: enqueueInputs in');
+ while (inputQueue.length > 0 && !inputEosFlag) {
+ let inputObject = inputQueue.shift();
+ console.log('in case: inputObject.index: ' + inputObject.index);
+ if (frameCountIn < ES_FRAME_SIZE.length) {
+ getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
+ inputObject.timeMs = timestamp;
+ inputObject.offset = 0;
+ inputObject.length = ES_FRAME_SIZE[frameCountIn];
+ position = position + ES_FRAME_SIZE[frameCountIn];
+ console.info('in case: frameCountIn ' + frameCountIn);
+ frameCountIn++;
+ timestamp += 1000 / mediaDescription.frame_rate;
+ }
+ if (isCodecData) {
+ inputObject.flags = 8;
+ isCodecData = false;
+ timestamp = 0;
+ } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
+ inputObject.flags = 1;
+ inputEosFlag = true;
+ } else {
+ inputObject.flags = 4;
+ }
+ videoDecodeProcessor.queueInput(inputObject).then(() => {
+ console.info('in case: queueInput success ');
+ }, caseCallback).catch(failCatch);
+ }
+ }
+
+ /* get outputbuffers from codec */
+ async function dequeueOutputs(nextStep) {
+ console.log('outputQueue.length:' + outputQueue.length);
+ while (outputQueue.length > 0){
+ let outputObject = outputQueue.shift();
+ if (outputObject.flags == 1 ) {
+ if (workdoneAtEOS) {
+ await doneWork();
+ nextStep();
+ }
+ return;
+ }
+ frameCountOut++;
+ videoDecodeProcessor.releaseOutput(outputObject, true).then(() => {
+ console.info('in case: release output success');
+ console.log('in case: release output count:' + frameCountOut);
+ }, caseCallback).catch(failCatch);
+ }
+ }
+
+ function toConfigure(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.configure(mediaDescription).then(() => {
+ console.info(`case configure success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toPrepare(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.prepare().then(() => {
+ console.info(`case prepare success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toStart(mySteps, done, failureCallback, catchCallback) {
+ let timeDelay = 0;
+ videoDecodeProcessor.start().then(() => {
+ console.info(`case start success`);
+ if (mySteps[0] == DECODE_STEP.FLUSH) {
+ timeDelay = 500;
+ }
+ setTimeout(() => {
+ toNextStep(mySteps, done);
+ }, timeDelay);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toFlush(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.flush().then(() => {
+ console.info(`case flush success`);
+ position = ES_FRAME_SIZE[0];
+ inputQueue = [];
+ timestamp = 0;
+ inputEosFlag = false;
+ frameCountIn = 1;
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toStop(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.stop().then(() => {
+ console.info(`case stop success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toReset(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.reset().then(() => {
+ console.info(`case reset success`);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+ function toSetOutputSurface(mySteps, done, failureCallback, catchCallback) {
+ videoDecodeProcessor.setOutputSurface(surfaceID, true).then(() => {
+ console.info('in case : setOutputSurface success, surfaceID ' + surfaceID);
+ toNextStep(mySteps, done);
+ }, (err) => {failureCallback(err, mySteps, done)}).catch(catchCallback);
+ }
+
+ function toNextStep(mySteps, done) {
+ console.info('case myStep[0]: ' + mySteps[0]);
+ if (mySteps[0] == DECODE_STEP.RELEASE) {
+ if (videoDecodeProcessor != null) {
+ videoDecodeProcessor.release().then(() => {
+ console.info('in case : videoDecodeProcessor release success');
+ videoDecodeProcessor = null;
+ console.info('case to done');
+ done();
+ }, failCallback).catch(failCatch);
+ }
+ return;
+ }
+ switch (mySteps[0]) {
+ case DECODE_STEP.CONFIGURE:
+ mySteps.shift();
+ console.info(`case to configure`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toConfigure(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toConfigure(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.SETSURFACE:
+ mySteps.shift();
+ console.info(`case to setOutputSurface`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toSetOutputSurface(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toSetOutputSurface(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.PREPARE:
+ mySteps.shift();
+ console.info(`case to prepare`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toPrepare(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toPrepare(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.START:
+ mySteps.shift();
+ console.info(`case to start`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStart(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ readStreamSync = undefined;
+ readFile(SRCPATH);
+ frameCountIn = 0;
+ frameCountOut = 0;
+ inputQueue = [];
+ outputQueue = [];
+ isCodecData = true;
+ inputEosFlag = false;
+ position = 0;
+ toStart(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.FLUSH:
+ mySteps.shift();
+ console.info(`case to flush`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toFlush(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toFlush(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.STOP:
+ mySteps.shift();
+ console.info(`case to stop`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toStop(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toStop(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.RESET:
+ mySteps.shift();
+ console.info(`case to reset`);
+ if (mySteps[0] == DECODE_STEP.ERROR) {
+ mySteps.shift();
+ toReset(mySteps, done, callbackExpectFail, failCatch);
+ } else {
+ toReset(mySteps, done, callbackExpectOK, failCatch);
+ }
+ break;
+ case DECODE_STEP.WAIT_FOR_EOS:
+ mySteps.shift();
+ setTimeout(() =>{
+ expect(inputEosFlag).assertTrue();
+ if (inputEosFlag == false) {
+ console.info(`in case error inputEosFlag == false`);
+ }
+ toNextStep(mySteps, done);
+ }, 7000); // wait 7000 ms for eos
+ break;
+ case DECODE_STEP.WAIT_FOR_ALL_OUTS:
+ mySteps.shift();
+ console.info(`case wait for all outputs`);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function setCallback(nextStep){
+ videoDecodeProcessor.on('inputBufferAvailable', async (inBuffer) => {
+ console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
+ inputQueue.push(inBuffer);
+ await enqueueInputs();
+ });
+
+ videoDecodeProcessor.on('outputBufferAvailable', async (outBuffer) => {
+ console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
+ outputQueue.push(outBuffer);
+ await dequeueOutputs(nextStep);
+ });
+
+ videoDecodeProcessor.on('error',(err) => {
+ console.info('in case: error called,errName is' + err);
+ });
+
+ videoDecodeProcessor.on('outputFormatChanged', (format) => {
+ console.info('in case: Output format changed: ' + format.toString());
+ });
+ }
+
+ function toCreateVideoDecoderByMime(mime, mySteps, done) {
+ media.createVideoDecoderByMime(mime).then((processor) => {
+ console.info(`case createVideoDecoderByMime success`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ }, failCallback).catch(failCatch);
+ }
+ function toCreateVideoDecoderByName(name, mySteps, done) {
+ media.createVideoDecoderByName(name).then((processor) => {
+ console.info(`case createVideoDecoderByName success`);
+ videoDecodeProcessor = processor;
+ setCallback(done);
+ toNextStep(mySteps, done);
+ }, failCallback).catch(failCatch);
+ }
+ async function doneWork() {
+ await videoDecodeProcessor.stop().then(() => {
+ console.info('case stop success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.reset().then(() => {
+ console.info('case reset success');
+ }, failCallback).catch(failCatch);
+ await videoDecodeProcessor.release().then(() => {
+ console.info('case release success');
+ }, failCallback).catch(failCatch);
+ videoDecodeProcessor = null;
+ }
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0100
+ * @tc.name : test set EOS manually before last frame and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0200
+ * @tc.name : test flush at running state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0300
+ * @tc.name : test flush at EOS state
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_ALL_OUTS);
+ eosFrameId = 50;
+ workdoneAtEOS = true;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0400
+ * @tc.name : test stop at running state and reset
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0500
+ * @tc.name : test stop and restart
+ * @tc.desc : test basic function
+ * @tc.size : MediumTest
+ * @tc.type : Function test
+ * @tc.level : Level0
+ */
+ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.CONFIGURE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_CONFIGURE_PROMISE_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_DECODER_API_CONFIGURE_PROMISE_0900', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS ,
+ DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_PREPARE_PROMISE_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_DECODER_API_PREPARE_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.PREPARE, DECODE_STEP.ERROR, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.START,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_START_PROMISE_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_DECODER_API_START_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.FLUSH,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP , DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_FLUSH_PROMISE_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_DECODER_API_FLUSH_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.FLUSH, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.STOP,
+ DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_STOP_PROMISE_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_DECODER_API_STOP_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.STOP, DECODE_STEP.ERROR, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.RESET,
+ DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.FLUSH, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0600', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.STOP, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0700', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_RESET_PROMISE_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_DECODER_API_RESET_PROMISE_0800', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.RESET, DECODE_STEP.RESET, DECODE_STEP.RELEASE);
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0100', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0200', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0300', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.RESET, DECODE_STEP.CONFIGURE, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0400', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+
+ /* *
+ * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_API_EOS_PROMISE_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_DECODER_API_EOS_PROMISE_0500', 0, async function (done) {
+ let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
+ DECODE_STEP.WAIT_FOR_EOS, DECODE_STEP.STOP, DECODE_STEP.START, DECODE_STEP.STOP, DECODE_STEP.RELEASE);
+ eosFrameId = 50;
+ toCreateVideoDecoderByName('avdec_h264', mySteps, done);
+ })
+})
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/element/string.json b/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/resources/base/media/icon.png b/multimedia/media/media_js_standard/videoDecoder/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/videoDecoder/src/main/resources/base/media/icon.png differ
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/info.txt b/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/info.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9632a32a7e0b92c0b921db34929e0f03c26a84df
--- /dev/null
+++ b/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/info.txt
@@ -0,0 +1 @@
+streamId:0 pts:0 pts_time:0.000000 size:197165 flag:1
\ No newline at end of file
diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/mp3_MP3.mp3 b/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/mp3_MP3.mp3
new file mode 100644
index 0000000000000000000000000000000000000000..2ac11d0b213c4686d6138e4234054ca13a15c63d
Binary files /dev/null and b/multimedia/media/media_js_standard/videoDecoder/src/main/resources/base/media/mp3_MP3.mp3 differ