提交 fa20bbbb 编写于 作者: L ling990

add testcases Signed-off-by: ling990 <liling96@huawei.com>

Signed-off-by: Nling990 <ling990@qq.com>
上级 c933ace1
# 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("audio_codec_format_js_hap") {
hap_profile = "./src/main/config.json"
js2abc = true
deps = [
":audio_codec_format_js_assets",
":audio_codec_format_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioCodecFormatJsTest"
subsystem_name = "multimedia"
part_name = "multimedia_player_framework"
}
ohos_js_assets("audio_codec_format_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("audio_codec_format_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for audio codec format Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "2000000",
"package": "ohos.acts.multimedia.audio.codecformat",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsAudioCodecFormatJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/audio/codecFormat/HEv2_AAC_2_96000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_96000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_96000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_8000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_8000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_11025.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_11025.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_12000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_12000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_16000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_16000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_2_22050.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/LC_AAC_1_22050.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_24000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_24000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_32000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_32000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_44100.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_44100.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_48000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_48000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_64000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_64000.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_1_88200.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/HE_AAC_2_88200.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_96000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_8000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_8000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_11025.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_11025.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_12000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_12000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_16000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_22050.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_16000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_22050.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_24000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_24000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_32000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_32000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_44100.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_44100.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_48000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_48000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_64000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_64000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_88200.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_1_88200.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/FLAC_2_96000.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_96000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_96000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_8000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_12000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_16000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_22050.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_24000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_32000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_44100.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_48000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_64000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_1_88200.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_8000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_12000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_16000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_22050.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_24000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_32000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_44100.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_48000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_64000.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"./resource/audio/codecFormat/S16LE_2_88200.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.audio.codecformat/haps/entry/files/*",
"chmod 777 -R /storage/media/100/local/files/",
"chmod 777 /storage/media/100/local/files/*"
],
"teardown-command":[
]
}
]
}
\ No newline at end of file
{
"app": {
"apiVersion": {
"compatible": 6,
"releaseType": "Beta1",
"target": 7
},
"vendor": "acts",
"bundleName": "ohos.acts.multimedia.audio.codecformat",
"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.audio.codecformat.MainAbility",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
}
],
"deviceType": [
"default",
"default",
"tablet",
"tv",
"wearable"
],
"reqPermissions": [
{
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.MEDIA_LOCATION",
"reason" : "use ohos.permission.MEDIA_LOCATION"
},
{
"name" : "ohos.permission.READ_MEDIA",
"reason" : "use ohos.permission.READ_MEDIA"
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"reason" : "use ohos.permission.WRITE_MEDIA"
}
],
"mainAbility": "ohos.acts.multimedia.audio.codecformat.MainAbility",
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.acts.multimedia.audio.codecformat",
"name": ".MyApplication",
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.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;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 600000
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
/*
* 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 featureAbility from '@ohos.ability.featureAbility'
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioEncoderFormatCompatibilityPromise', function () {
let audioEncodeProcessor;
let eosframenum = 0;
let resetAtEOS = false;
let workdoneAtEOS = false;
let needgetMediaDes = false;
let needrelease = false;
let frameCnt = 1;
let timestamp = 0;
let rate = 0;
let sawInputEOS = false;
let sawOutputEOS = false;
let inputQueue = [];
let outputQueue = [];
let ES = [0, 2048];
let ES_LENGTH = 1000;
let readPath;
let fdRead;
let fdWrite;
let readStreamSync;
let fileAssetWrite;
let channelCount;
let channelCountList = [];
let sampleRateList = [];
let formatSampleRate = [];
const events = require('events');
const eventEmitter = new events.EventEmitter();
const context = featureAbility.getContext();
let outputCnt = 0;
let inputCnt = 0;
let frameThreshold = 10;
beforeAll(async function() {
console.info('beforeAll case 1');
})
beforeEach(function() {
console.info('beforeEach case');
outputCnt = 0;
inputCnt = 0;
})
afterEach(async function() {
console.info('afterEach case');
if (audioEncodeProcessor != null) {
console.info('case audioEncodeProcessor is not null');
await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null;
}, failCallback).catch(failCatch);
}
})
afterAll(function() {
console.info('afterAll case');
})
let failCallback = function(err) {
console.info('case callback err : ' + err);
expect(err).assertUndefined();
}
let failCatch = function(err) {
console.info('case catch err : ' + err);
expect(err).assertUndefined();
}
async function resetParam() {
eosframenum = 0;
resetAtEOS = false;
workdoneAtEOS = false;
needgetMediaDes = false;
needrelease = false
frameCnt = 1;
timestamp = 0;
rate = 0;
sawInputEOS = false;
sawOutputEOS = false;
readStreamSync = undefined;
inputQueue = [];
outputQueue = [];
ES = [0, 4096]
ES_LENGTH = 1000;
outputCnt = 0;
inputCnt = 0;
}
async function beforeTest() {
console.info('beforeTest case');
audioEncodeProcessor = null;
eosframenum = 0;
resetAtEOS = false;
workdoneAtEOS = false;
needgetMediaDes = false;
needrelease = false
frameCnt = 1;
timestamp = 0;
rate = 0;
sawInputEOS = false;
sawOutputEOS = false;
readStreamSync = undefined;
inputQueue = [];
outputQueue = [];
ES = [0, 4096]
ES_LENGTH = 1000;
}
async function aferTest() {
console.info('afterTest case');
if (audioEncodeProcessor != null) {
console.info('case audioEncodeProcessor is not null');
await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null;
}, failCallback).catch(failCatch);
}
await closeFdRead();
inputCnt = 0;
outputCnt = 0;
}
async function getFdRead(readPath, done) {
await mediaTestBase.getFdRead(readPath, done).then((fdNumber) => {
fdRead = fdNumber;
})
}
async function closeFdRead() {
await fileio.close(fdRead).then(() => {
console.info('[fileio] case close fdRead success, fd is ' + fdRead);
}, failCallback).catch(failCatch);
}
function writeFile(buf, len) {
try{
let res = fileio.writeSync(fdWrite, buf, {length: len});
console.info('case fileio.write buffer success');
} catch(e) {
console.info('case fileio.write buffer error is ' + e);
}
}
function readFile(path) {
console.info('read file start execution');
try{
console.info('filepath: ' + path);
readStreamSync = fileio.fdopenStreamSync(fdRead, 'rb');
}catch(e) {
console.info(e);
}
}
function getContent(buf, len) {
console.info("case start get content");
let lengthreal = -1;
lengthreal = fileio.readSync(fdRead, buf, {length:len});
console.info('case lengthreal is :' + lengthreal);
}
async function resetWork() {
resetParam();
await audioEncodeProcessor.reset().then(async() => {
console.info("case reset success");
if (needrelease) {
await audioEncodeProcessor.release().then(() => {
console.info("case release success");
}, failCallback).catch(failCatch);
audioEncodeProcessor = null;
}
}, failCallback).catch(failCatch);
}
async function doneWork() {
await audioEncodeProcessor.stop().then(() => {
console.info("case stop success");
}, failCallback).catch(failCatch);
resetParam();
await audioEncodeProcessor.reset().then(() => {
console.info("case reset success");
}, failCallback).catch(failCatch);
await audioEncodeProcessor.release().then(() => {
console.info("case release success");
}, failCallback).catch(failCatch);
audioEncodeProcessor = null;
}
async function enqueueInputs(queue) {
while (queue.length > 0 && !sawInputEOS) {
let inputobject = queue.shift();
console.info("case frameCnt:" + frameCnt);
if (frameCnt == eosframenum || frameCnt == ES_LENGTH + 1) {
console.info("case EOS frame seperately")
inputobject.flags = 1;
inputobject.timeMs = 0;
inputobject.length = 0;
sawInputEOS = true;
} else {
console.info("case read frame from file");
inputobject.timeMs = timestamp;
inputobject.offset = 0;
inputobject.length = ES[1];
getContent(inputobject.data, ES[1]);
inputobject.flags = 0;
}
timestamp += 23;
frameCnt += 1;
audioEncodeProcessor.pushInputData(inputobject).then(() => {
console.info('case queueInput success');
inputCnt += 1;
});
}
}
async function dequeueOutputs(queue, nextStep, done) {
while (queue.length > 0 && !sawOutputEOS) {
let outputObject = queue.shift();
if (outputObject.flags == 1) {
sawOutputEOS = true;
expect(outputCnt).assertClose(inputCnt, frameThreshold);
await doneWork();
if(sampleRateList == false && channelCountList[0] != undefined) {
await aferTest();
channelCount = channelCountList.shift();
sampleRateList = formatSampleRate.toString().split(',');
console.info('channelCountList[0]: ' + channelCountList[0]);
console.info('formatSampleRate ' + formatSampleRate);
nextStep();
return;
}else if (channelCountList == false && sampleRateList == false) {
done();
} else {
await aferTest();
nextStep();
return;
}
} else {
console.info("write to file success");
}
audioEncodeProcessor.freeOutputBuffer(outputObject).then(() => {
console.info('release output success');
});
}
}
function printfDescription(obj) {
for (let item in obj) {
let property = obj[item];
console.info("AudioEncoder config is" + item + ":" + property);
}
}
function setCallback(nextStep, done) {
console.info('case callback');
audioEncodeProcessor.on('needInputData', async(inBuffer) => {
console.info('inputBufferAvailable');
inputQueue.push(inBuffer);
await enqueueInputs(inputQueue);
});
audioEncodeProcessor.on('newOutputData', async(outBuffer) => {
console.info('outputBufferAvailable');
outputCnt += 1;
if (outputCnt == 1 && outBuffer.flags == 1) {
console.info("case error occurs! first output is EOS");
expect().assertFail();
}
if (needgetMediaDes) {
audioEncodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
console.info("get OutputMediaDescription success");
console.info('get outputMediaDescription : ' + MediaDescription);
needgetMediaDes=false;
}, failCallback).catch(failCatch);
}
outputQueue.push(outBuffer);
await dequeueOutputs(outputQueue, nextStep, done);
});
audioEncodeProcessor.on('error',(err) => {
console.info('case error called,errName is' + err);
});
audioEncodeProcessor.on('streamChanged',(format) => {
console.info('Output format changed: ' + format);
});
}
eventEmitter.on('nextStep', async (done) => {
console.info('in case : nextStep success');
await beforeTest();
let sampleRate = Number(sampleRateList.shift());
let savePath = `AAC_LC_${channelCount}_${sampleRate}.aac`;
let srcPath = `S16LE_${channelCount}_${sampleRate}.pcm`;
if (channelCount === 2) {
ES = [0, 4096];
} else {
ES = [0, 2048];
}
let mediaDescription = {
"channel_count": channelCount,
"sample_rate": sampleRate,
"audio_sample_format": 1,
"codec_mime": 'audio/mp4a-latm',
}
await encodeSource(mediaDescription, savePath, srcPath, done);
});
async function getFormatCaps() {
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success");
audioEncodeProcessor = processor;
}, failCallback).catch(failCatch);
await audioEncodeProcessor.getAudioEncoderCaps().then((AudioCaps) => {
console.info("case get AudioEncoderCaps success");
console.info("print AudioCaps: " + AudioCaps)
console.info("print AudioCaps.supportedSampleRates: " + AudioCaps.supportedSampleRates)
console.info("print AudioCaps.supportedChannel.min: " + AudioCaps.supportedChannel.min)
console.info("print AudioCaps.supportedChannel.max: " + AudioCaps.supportedChannel.max)
formatSampleRate = AudioCaps.supportedSampleRates;
for (let i = AudioCaps.supportedChannel.min; i <= AudioCaps.supportedChannel.max; i++) {
channelCountList.push(i);
}
}, failCallback).catch(failCatch);
await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null;
}, failCallback).catch(failCatch);
}
async function encodeSource(config, savePath, srcPath, done){
console.info('start test case');
let mediaDescription = config;
readPath = srcPath;
needgetMediaDes = true;
workdoneAtEOS = true;
await getFdRead(readPath, done);
console.info('case getFdRead success');
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success");
audioEncodeProcessor = processor;
}, failCallback).catch(failCatch);
await audioEncodeProcessor.getAudioEncoderCaps().then((AudioCaps) => {
console.info("case get AudioEncoderCaps success");
console.info("print AudioCaps: " + AudioCaps)
}, failCallback).catch(failCatch);
await audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info("case configure success");
}, failCallback).catch(failCatch);
setCallback(function(){eventEmitter.emit('nextStep', done);}, done);
await audioEncodeProcessor.prepare().then(() => {
console.info("case prepare success");
}, failCallback).catch(failCatch);
await audioEncodeProcessor.start().then(() => {
console.info("case start success")
}, failCallback).catch(failCatch);
await audioEncodeProcessor.getOutputMediaDescription().then((mediaDescription) => {
console.info("getOutputMediaDescription success");
printfDescription(mediaDescription);
},failCallback).catch(failCatch);
audioEncodeProcessor.on('error',(err) => {
console.info(`case error called,errName is ${err.name}`);
console.info(`case error called,errCode is ${err.code}`);
console.info(`case error called,errMessage is ${err.message}`);
expect().assertFail();
done();
});
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_ENCODER_FORMAT_COMPATIBILITY_AAC_PROMISE_0100
* @tc.name : 01.test acc format compatibility
* @tc.desc : audio encoder format compatibility test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_AUDIO_ENCODER_FORMAT_COMPATIBILITY_AAC_PROMISE_0100', 0, async function (done) {
console.info("case test acc format compatibility");
await getFormatCaps();
sampleRateList = formatSampleRate.toString().split(',');
channelCount = channelCountList.shift();
let nextStep = eventEmitter.emit('nextStep', done);
nextStep();
})
})
\ No newline at end of file
/*
* 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('./AudioEncoderFormatCompatibilityPromiseTest.test.js')
require('./AudioDecoderFormatCompatibilityPromiseTest.test.js')
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("audio_decoder_js_hap") {
hap_profile = "./src/main/config.json"
js2abc = true
deps = [
":audio_decoder_js_assets",
":audio_decoder_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioDecoderJsTest"
subsystem_name = "multimedia"
part_name = "multimedia_player_framework"
}
ohos_js_assets("audio_decoder_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("audio_decoder_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for audioDecoder Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "2000000",
"package": "ohos.acts.multimedia.audio.audiodecoder",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAudioDecoderJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/audio/audioDecode/AAC_48000_32_1.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"./resource/audio/audioDecode/AAC_16000_1.aac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"./resource/audio/audioDecode/FLAC_48000_32_1.flac ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"./resource/audio/audioDecode/mp3.es ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"./resource/audio/audioDecode/vorbis.es ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.audio.audiodecoder/haps/entry/files/*",
"chmod 777 -R /storage/media/100/local/files/",
"chmod 777 /storage/media/100/local/files/*"
],
"teardown-command":[
]
}
]
}
\ No newline at end of file
{
"app": {
"apiVersion": {
"compatible": 6,
"releaseType": "Beta1",
"target": 7
},
"vendor": "acts",
"bundleName": "ohos.acts.multimedia.audio.audiodecoder",
"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.audio.audiodecoder.MainAbility",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
}
],
"deviceType": [
"default",
"default",
"tablet",
"tv",
"wearable"
],
"reqPermissions": [
{
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.MEDIA_LOCATION",
"reason" : "use ohos.permission.MEDIA_LOCATION"
},
{
"name" : "ohos.permission.READ_MEDIA",
"reason" : "use ohos.permission.READ_MEDIA"
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"reason" : "use ohos.permission.WRITE_MEDIA"
}
],
"mainAbility": "ohos.acts.multimedia.audio.audiodecoder.MainAbility",
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.acts.multimedia.audio.audiodecoder",
"name": ".MyApplication",
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.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;
}
}
<!--
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 60000
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioDecoderEnum', function () {
beforeAll(function() {
console.info('beforeAll case');
})
beforeEach(function() {
console.info('beforeEach case');
})
afterEach(function() {
console.info('afterEach case');
})
afterAll(function() {
console.info('afterAll case');
})
let failCallback = function(err) {
console.info('case callback err : ' + err);
expect(err).assertUndefined();
}
let failCatch = function(err) {
console.info('case catch err : ' + err);
expect(err).assertUndefined();
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AACProfile_0100
* @tc.name : 001.AACProfile
* @tc.desc : Test Enumerate AACProfile
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AACProfile_0100', 0, async function (done) {
expect(media.AACProfile.AAC_PROFILE_LC).assertEqual(0);
expect(media.AACProfile.AAC_PROFILE_ELD).assertEqual(1);
expect(media.AACProfile.AAC_PROFILE_ERLC).assertEqual(2);
expect(media.AACProfile.AAC_PROFILE_HE).assertEqual(3);
expect(media.AACProfile.AAC_PROFILE_HE_V2).assertEqual(4);
expect(media.AACProfile.AAC_PROFILE_LD).assertEqual(5);
expect(media.AACProfile.AAC_PROFILE_MAIN).assertEqual(6);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AudioCaps_0100
* @tc.name : 002.AudioCaps
* @tc.desc : Test Interface AudioCaps
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AudioCaps_0100', 0, async function (done) {
console.info("case test Test Interface AudioCaps");
let audioDecodeProcessor;
let audioCaps;
await media.createAudioDecoderByName('avdec_aac').then((processor) => {
console.log("create createAudioDecoder success");
audioDecodeProcessor = processor;
}, failCallback).catch(failCatch);
await audioDecodeProcessor.getAudioDecoderCaps().then((AudioCaps) => {
console.log("get AudioDecoderCaps success");
audioCaps = AudioCaps;
}, failCallback).catch(failCatch);
// check AudioCaps
expect(audioCaps.codecInfo !== undefined).assertTrue();
// check AudioCaps.AVCodecInfo
let avCodecInfo = audioCaps.codecInfo;
expect(avCodecInfo.name !== undefined).assertTrue();
console.info('avCodecInfo.name: '+ avCodecInfo.name);
expect(avCodecInfo.type !== undefined).assertTrue();
console.info('avCodecInfo.type: '+ avCodecInfo.type);
expect(avCodecInfo.mimeType !== undefined).assertTrue();
console.info('avCodecInfo.mimeType: '+ avCodecInfo.mimeType);
expect(avCodecInfo.isHardwareAccelerated !== undefined).assertTrue();
console.info('avCodecInfo.isHardwareAccelerated: '+ avCodecInfo.isHardwareAccelerated);
expect(avCodecInfo.isSoftwareOnly !== undefined).assertTrue();
console.info('avCodecInfo.isSoftwareOnly: '+ avCodecInfo.isSoftwareOnly);
expect(avCodecInfo.isVendor !== undefined).assertTrue();
console.info('avCodecInfo.isVendor: '+ avCodecInfo.isVendor);
// check AudioCaps.supportedBitrate
expect(audioCaps.supportedBitrate !== undefined).assertTrue();
console.info('supportedBitrate.min: '+ audioCaps.supportedBitrate.min);
console.info('supportedBitrate.max: '+ audioCaps.supportedBitrate.max);
// check AudioCaps.supportedChannel
expect(audioCaps.supportedChannel !== undefined).assertTrue();
console.info('supportedChannel.min: '+ audioCaps.supportedChannel.min);
console.info('supportedChannel.max: '+ audioCaps.supportedChannel.max);
// check AudioCaps.supportedFormats
expect(audioCaps.supportedFormats !== undefined).assertTrue();
console.info('audioCaps.supportedFormats: '+ audioCaps.supportedFormats);
// check AudioCaps.supportedSampleRates
expect(audioCaps.supportedSampleRates !== undefined).assertTrue();
console.info('audioCaps.supportedSampleRates: '+ audioCaps.supportedSampleRates);
// check AudioCaps.supportedProfiles
expect(audioCaps.supportedProfiles !== undefined).assertTrue();
console.info('audioCaps.supportedProfiles: '+ audioCaps.supportedProfiles);
// check AudioCaps.supportedComplexity
expect(audioCaps.supportedComplexity !== undefined).assertTrue();
console.info('supportedComplexity.min: '+ audioCaps.supportedComplexity.min);
console.info('supportedComplexity.max: '+ audioCaps.supportedComplexity.max);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AVCodecType_0100
* @tc.name : 003.AVCodecType
* @tc.desc : Test Enumerate AVCodecType
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_ENUM_AVCodecType_0100', 0, async function (done) {
expect(media.AVCodecType.AVCODEC_TYPE_VIDEO_ENCODER).assertEqual(0);
expect(media.AVCodecType.AVCODEC_TYPE_VIDEO_DECODER).assertEqual(1);
expect(media.AVCodecType.AVCODEC_TYPE_AUDIO_ENCODER).assertEqual(2);
expect(media.AVCodecType.AVCODEC_TYPE_AUDIO_DECODER).assertEqual(3);
done();
})
})
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import media from '@ohos.multimedia.media'
import fileio from '@ohos.fileio'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioDecoderMultiInstances', function () {
const AUDIOPATH = 'AAC_48000_32_1.aac';
let readStreamSync;
let eosframenum = 0;
let samplerate = 44.1;
let stopAtEOS = false;
let resetAtEOS = false;
let flushAtEOS = false;
let workdoneAtEOS = false;
let needGetMediaDes = false;
let needrelease = false;
let frameCnt = 1;
let timestamp = 0;
let sawInputEOS = false;
let sawOutputEOS = false;
let inputQueue = [];
let outputQueue = [];
let ES = [];
let ES_LENGTH = 1500;
beforeAll(function() {
console.info('beforeAll case');
})
beforeEach(function() {
console.info('beforeEach case');
})
afterEach(function() {
console.info('afterEach case');
})
afterAll(function() {
console.info('afterAll case');
})
let failCallback = function(err) {
console.info('case callback err : ' + err);
expect(err).assertUndefined();
}
let failCatch = function(err) {
console.info('case catch err : ' + err);
expect(err).assertUndefined();
}
function resetParam() {
readStreamSync = undefined;
eosframenum = 0;
samplerate = 44.1;
stopAtEOS = false;
resetAtEOS = false;
flushAtEOS = false;
workdoneAtEOS = false;
needGetMediaDes = false;
needrelease = false;
frameCnt = 1;
timestamp = 0;
sawInputEOS = false;
sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
}
function writeFile(path, buf, len) {
try{
let writestream = fileio.createStreamSync(path, "ab+");
let num = writestream.writeSync(buf, {length:len});
writestream.flushSync();
writestream.closeSync();
}catch(e) {
console.info(e)
}
}
function readFile(path) {
console.info('read file start execution');
try{
console.info('filepath: ' + path);
readStreamSync = fileio.createStreamSync(path, 'rb');
}catch(e) {
console.info(e);
}
}
function getContent(buf, len) {
console.info("case start get content");
let lengthreal = -1;
lengthreal = readStreamSync.readSync(buf,{length:len});
}
async function stopWork(audioDecodeProcessor) {
await audioDecodeProcessor.stop().then(() => {
console.info("case stop success")
}, failCallback).catch(failCatch);
}
async function resetWork(audioDecodeProcessor) {
resetParam();
await audioDecodeProcessor.reset().then(() => {
console.info("case reset success");
if (needrelease) {
audioDecodeProcessor = null;
}
}, failCallback).catch(failCatch);
}
async function flushWork(audioDecodeProcessor) {
inputQueue = [];
outputQueue = [];
await audioDecodeProcessor.flush().then(() => {
console.info("case flush at inputeos success");
resetParam();
readFile(AUDIOPATH);
workdoneAtEOS =true;
}, failCallback).catch(failCatch);
}
async function doneWork(audioDecodeProcessor) {
await audioDecodeProcessor.stop().then(() => {
console.info("case stop success");
}, failCallback).catch(failCatch);
resetParam();
await audioDecodeProcessor.reset().then(() => {
console.info("case reset success");
}, failCallback).catch(failCatch);
audioDecodeProcessor = null;
}
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
function wait(time) {
for(let t = Date.now(); Date.now() - t <= time;);
}
async function enqueueAllInputs(audioDecodeProcessor, queue) {
while (queue.length > 0 && !sawInputEOS) {
let inputobject = queue.shift();
if (frameCnt == eosframenum || frameCnt == ES_LENGTH + 1) {
inputobject.flags = 1;
inputobject.timeMs = 0;
inputobject.length = 0;
sawInputEOS = true;
} else {
console.info("case read frame from file");
inputobject.timeMs = timestamp;
inputobject.offset = 0;
inputobject.length = ES[frameCnt];
getContent(inputobject.data, ES[frameCnt]);
inputobject.flags = 0;
}
timestamp += ES[frameCnt]/samplerate;
frameCnt += 1;
audioDecodeProcessor.pushInputData(inputobject).then(() => {
console.info('case queueInput success');
});
}
}
async function dequeueAllOutputs(audioDecodeProcessor, queue, savapath, done) {
while (queue.length > 0 && !sawOutputEOS) {
let outputobject = queue.shift();
if (outputobject.flags == 1) {
sawOutputEOS = true;
console.info("sawOutputEOS == true");
if (stopAtEOS) {
await stopWork(audioDecodeProcessor);
} else if (resetAtEOS) {
await resetWork(audioDecodeProcessor);
} else if (flushAtEOS) {
await flushWork(audioDecodeProcessor);
} else if (workdoneAtEOS) {
await doneWork(audioDecodeProcessor);
done();
} else {
console.info("saw output EOS");
}
}
else{
writeFile(savapath, outputobject.data, outputobject.length);
console.info("write to file success");
}
audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success');
});
}
}
function setCallback(audioDecodeProcessor, savepath, done) {
console.info('case callback');
audioDecodeProcessor.on('needInputData', async(inBuffer) => {
console.info('inputBufferAvailable');
inputQueue.push(inBuffer);
await enqueueAllInputs(audioDecodeProcessor, inputQueue);
});
audioDecodeProcessor.on('newOutputData', async(outBuffer) => {
console.info('outputBufferAvailable');
console.info("outputbuffer.flags: " + outBuffer.flags);
if (needGetMediaDes) {
audioDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
console.info("get OutputMediaDescription success");
console.info('get outputMediaDescription : ' + MediaDescription);
needGetMediaDes=false;
}, failCallback).catch(failCatch);}
outputQueue.push(outBuffer);
await dequeueAllOutputs(audioDecodeProcessor, outputQueue, savepath, done);
});
audioDecodeProcessor.on('error',(err) => {
console.info('case error called,errName is' + err);
});
audioDecodeProcessor.on('streamChanged',(format) => {
console.info('Output format changed: ' + format);
});
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_MULTIINSTANCE_0100
* @tc.name : 001.create multiple decoders
* @tc.desc : basic decode function
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_AUDIO_DECODER_MULTIINSTANCE_0100', 0, async function (done) {
console.info("case test multiple instances");
let array = new Array();
for (let i = 0; i < 2; i += 1) {
await media.createAudioDecoderByMime('audio/mp4a-latm').then((processor) => {
if (typeof(processor) != 'undefined') {
console.info("case create createAudioDecoder success: " + i);
array[i] = processor;
} else {
console.info("case create createAudioDecoder failed: " + i);
}
}, failCallback).catch(failCatch);
}
console.info('case has created multiple decoders');
for (let j = 0; j < 2; j++) {
resetParam();
await array[j].reset().then(() => {
console.info("reset decoder " + j);
}, failCallback).catch(failCatch);
await array[j].release().then(() => {
console.info('release success');
array[j] = null;
}, failCallback).catch(failCatch);
}
done();
})
})
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./AudioDecoderFuncPromiseTest.test.js')
require('./AudioDecoderFuncCallbackTest.test.js')
require('./AudioDecoderFormatPromiseTest.test.js')
require('./AudioDecoderFormatCallbackTest.test.js')
require('./AudioDecoderReliabilityPromiseTest.test.js')
require('./AudioDecoderReliabilityCallbackTest.test.js')
require('./AudioDecoderMultiInstancesTest.test.js')
require('./AudioDecoderEnumTest.test.js')
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("audio_encoder_js_hap") {
hap_profile = "./src/main/config.json"
js2abc = true
deps = [
":audio_encoder_js_assets",
":audio_encoder_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioEncoderJsTest"
subsystem_name = "multimedia"
part_name = "multimedia_player_framework"
}
ohos_js_assets("audio_encoder_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("audio_encoder_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for audioEncoder Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "2000000",
"package": "ohos.acts.multimedia.audio.audioencoder",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAudioEncoderJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files/",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files/"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/audio/audioEncode/S16LE.pcm ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files/"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files/",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioencoder/haps/entry/files/*",
"chmod 777 -R /storage/media/100/local/files/",
"chmod 777 /storage/media/100/local/files/*"
],
"teardown-command":[
]
}
]
}
\ No newline at end of file
{
"app": {
"apiVersion": {
"compatible": 6,
"releaseType": "Beta1",
"target": 7
},
"vendor": "acts",
"bundleName": "ohos.acts.multimedia.audio.audioencoder",
"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.audio.audioencoder.MainAbility",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
}
],
"deviceType": [
"default",
"default",
"tablet",
"tv",
"wearable"
],
"reqPermissions": [
{
"name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name" : "ohos.permission.MEDIA_LOCATION",
"reason" : "use ohos.permission.MEDIA_LOCATION"
},
{
"name" : "ohos.permission.READ_MEDIA",
"reason" : "use ohos.permission.READ_MEDIA"
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"reason" : "use ohos.permission.WRITE_MEDIA"
}
],
"mainAbility": "ohos.acts.multimedia.audio.audioencoder.MainAbility",
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.acts.multimedia.audio.audioencoder",
"name": ".MyApplication",
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.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;
}
}
<!--
Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 60000
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./AudioEncoderFuncCallbackTest.test.js')
require('./AudioEncoderFuncPromiseTest.test.js')
require('./AudioEncoderReliabilityCallbackTest.test.js')
require('./AudioEncoderReliabilityPromiseTest.test.js')
require('./AudioEncoderMultiInstancesTest.test.js')
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("video_codec_format_js_hap") {
hap_profile = "./src/main/config.json"
js2abc = true
deps = [
":video_codec_format_js_assets",
":video_codec_format_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsVideoCodecFormatJsTest"
subsystem_name = "multimedia"
part_name = "multimedia_player_framework"
}
ohos_js_assets("video_codec_format_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("video_codec_format_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for video codec format Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "2000000",
"package": "ohos.acts.multimedia.video.codecformat",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsVideoCodecFormatJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/"
],
"teardown-command":[
]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/media/es/H264_BP_720_480_10_3000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_BP_720_480_30_768000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_BP_720_480_30_2000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_HP_352_288_30_3000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_HP_640_480_30_3000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_HP_720_480_25_3000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_HP_720_480_30_3000000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_MP_720_480_30_64000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_MP_720_480_30_128000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_MP_720_480_30_192000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"./resource/media/es/H264_MP_720_480_30_384000.h264 ->/data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/",
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.video.codecformat/haps/entry/files/*"
],
"teardown-command":[
]
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册