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

!2801 修改音频编码资源文件测试代码+代码整改

Merge pull request !2801 from ling990/OpenHarmony-3.1-Release
...@@ -28,7 +28,6 @@ describe('AudioDecoderEnum', function () { ...@@ -28,7 +28,6 @@ describe('AudioDecoderEnum', function () {
afterEach(function() { afterEach(function() {
console.info('afterEach case'); console.info('afterEach case');
wait(2000);
}) })
afterAll(function() { afterAll(function() {
......
...@@ -538,8 +538,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -538,8 +538,7 @@ describe('AudioDecoderReliabilityCallback', function () {
} }
} }
else{ else{
writeFile(savepath, outputobject.data, outputobject.length); console.info("not last frame, continue");
console.info("write to file success");
} }
audioDecodeProcessor.freeOutputBuffer(outputobject, () => { audioDecodeProcessor.freeOutputBuffer(outputobject, () => {
console.info('release output success'); console.info('release output success');
......
...@@ -541,8 +541,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -541,8 +541,7 @@ describe('AudioDecoderReliabilityPromise', function () {
} }
} }
else{ else{
writeFile(savapath, outputobject.data, outputobject.length); console.info("not last frame, continue");
console.info("write to file success");
} }
audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => { audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success'); console.info('release output success');
......
{ {
"description": "Configuration for audioPlayer Tests", "description": "Configuration for audioEncoder Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "2000000", "test-timeout": "2000000",
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/audio/audioEncode/S32LE.pcm ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/", "./resource/audio/audioEncode/S16LE.pcm ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/"
"./resource/audio/audioEncode/S32LE_2.pcm ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/"
] ]
}, },
{ {
......
...@@ -19,8 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -19,8 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('AudioEncoderFuncCallback', function () { describe('AudioEncoderFuncCallback', function () {
const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/' const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/'
const AUDIOPATH = RESOURCEPATH + 'S32LE.pcm'; const AUDIOPATH = RESOURCEPATH + 'S16LE.pcm';
const AUDIOPATH2 = RESOURCEPATH + 'S32LE_2.pcm';
const BASIC_PATH = RESOURCEPATH + 'results/encode_func_callback_'; const BASIC_PATH = RESOURCEPATH + 'results/encode_func_callback_';
let audioEncodeProcessor; let audioEncodeProcessor;
let readStreamSync; let readStreamSync;
...@@ -61,7 +60,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -61,7 +60,7 @@ describe('AudioEncoderFuncCallback', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
ES_LENGTH = 2000; ES_LENGTH = 1500;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -139,8 +138,8 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -139,8 +138,8 @@ describe('AudioEncoderFuncCallback', function () {
console.info("start add ADTS to Packet"); console.info("start add ADTS to Packet");
let packetLen = len + 7; // 7: head length let packetLen = len + 7; // 7: head length
let profile = 2; // 2: AAC LC let profile = 2; // 2: AAC LC
let freqIdx = 3; // 3: 48000HZ let freqIdx = 4; // 4: 44100HZ
let chanCfg = 1; // 1: 1 channel let chanCfg = 2; // 2: 2 channel
view[0] = 0xFF; view[0] = 0xFF;
view[1] = 0xF9; view[1] = 0xF9;
view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2); view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2);
...@@ -163,7 +162,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -163,7 +162,11 @@ describe('AudioEncoderFuncCallback', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
audioEncodeProcessor = null audioEncodeProcessor.release((err) => {
expect(err).assertUndefined();
console.info("case release success");
audioEncodeProcessor = null;
})
} }
}) })
} }
...@@ -299,14 +302,14 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -299,14 +302,14 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let mediaDescription2 = { let mediaDescription2 = {
"codec_mime": 'audio/mp4a-latm', "codec_mime": 'audio/mp4a-latm',
} }
let savepath = BASIC_PATH + 'callback0000.es'; let savepath = BASIC_PATH + '0000.aac';
needGetMediaDes = true; needGetMediaDes = true;
workdoneAtEOS = true; workdoneAtEOS = true;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
...@@ -382,11 +385,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -382,11 +385,11 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0100.es'; let savepath = BASIC_PATH + '0100.aac';
eosframenum = 500; eosframenum = 500;
workdoneAtEOS = true; workdoneAtEOS = true;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
...@@ -440,11 +443,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -440,11 +443,11 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0200.es'; let savepath = BASIC_PATH + '0200.aac';
workdoneAtEOS = true; workdoneAtEOS = true;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => { audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => {
...@@ -506,11 +509,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -506,11 +509,11 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0300.es'; let savepath = BASIC_PATH + '0300.aac';
eosframenum = 500; eosframenum = 500;
flushAtEOS = true; flushAtEOS = true;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
...@@ -564,11 +567,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -564,11 +567,11 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0400.es'; let savepath = BASIC_PATH + '0400.aac';
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => { audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
...@@ -646,11 +649,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -646,11 +649,11 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0500.es'; let savepath = BASIC_PATH + '0500.aac';
eosframenum = 100; eosframenum = 100;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => { audioEncodeProcessor.getAudioEncoderCaps((err, Audiocaps) => {
...@@ -725,17 +728,17 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -725,17 +728,17 @@ describe('AudioEncoderFuncCallback', function () {
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + 'callback0600.es'; let savepath = BASIC_PATH + '0600.aac';
eosframenum = 100; eosframenum = 100;
resetAtEOS = true; resetAtEOS = true;
let mediaDescription2 = { let mediaDescription2 = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let hasreconfigured = false; let hasreconfigured = false;
eventEmitter.on('getAudioEncoderCaps', () => { eventEmitter.on('getAudioEncoderCaps', () => {
...@@ -777,8 +780,8 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -777,8 +780,8 @@ describe('AudioEncoderFuncCallback', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case configure 2`); console.info(`case configure 2`);
resetParam(); resetParam();
readFile(AUDIOPATH2) readFile(AUDIOPATH)
savepath = BASIC_PATH + 'callback0601.es'; savepath = BASIC_PATH + '0601.aac';
workdoneAtEOS = true; workdoneAtEOS = true;
hasreconfigured = true; hasreconfigured = true;
eventEmitter.emit('prepare'); eventEmitter.emit('prepare');
......
...@@ -19,8 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -19,8 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('AudioEncoderFuncPromise', function () { describe('AudioEncoderFuncPromise', function () {
const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/' const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/'
const AUDIOPATH = RESOURCEPATH + 'S32LE.pcm'; const AUDIOPATH = RESOURCEPATH + 'S16LE.pcm';
const AUDIOPATH2 = RESOURCEPATH + 'S32LE_2.pcm';
const BASIC_PATH = RESOURCEPATH + 'results/encode_func_promise_'; const BASIC_PATH = RESOURCEPATH + 'results/encode_func_promise_';
let audioEncodeProcessor; let audioEncodeProcessor;
let readStreamSync; let readStreamSync;
...@@ -38,7 +37,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -38,7 +37,7 @@ describe('AudioEncoderFuncPromise', function () {
let inputQueue = []; let inputQueue = [];
let outputQueue = []; let outputQueue = [];
const ES = [0, 4096]; const ES = [0, 4096];
let ES_LENGTH = 2000; let ES_LENGTH = 1500;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -61,7 +60,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -61,7 +60,7 @@ describe('AudioEncoderFuncPromise', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
ES_LENGTH = 2000; ES_LENGTH = 1500;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -150,8 +149,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -150,8 +149,8 @@ describe('AudioEncoderFuncPromise', function () {
console.info("start add ADTS to Packet"); console.info("start add ADTS to Packet");
let packetLen = len + 7; // 7: head length let packetLen = len + 7; // 7: head length
let profile = 2; // 2: AAC LC let profile = 2; // 2: AAC LC
let freqIdx = 3; // 3: 48000HZ let freqIdx = 4; // 4: 44100HZ
let chanCfg = 1; // 1: 1 channel let chanCfg = 2; // 2: 2 channel
view[0] = 0xFF; view[0] = 0xFF;
view[1] = 0xF9; view[1] = 0xF9;
view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2); view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2);
...@@ -169,9 +168,12 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -169,9 +168,12 @@ describe('AudioEncoderFuncPromise', function () {
async function resetWork() { async function resetWork() {
resetParam(); resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(async() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
await audioEncodeProcessor.release().then(() => {
console.info("case release success");
}, failCallback).catch(failCatch);
audioEncodeProcessor = null; audioEncodeProcessor = null;
} }
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -202,7 +204,6 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -202,7 +204,6 @@ describe('AudioEncoderFuncPromise', function () {
audioEncodeProcessor = null; audioEncodeProcessor = null;
} }
function sleep(time) { function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time)); return new Promise((resolve) => setTimeout(resolve, time));
} }
...@@ -304,14 +305,14 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -304,14 +305,14 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_00_0100', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_00_0100', 0, async function (done) {
console.info("case test set EOS after last frame and reset"); console.info("case test set EOS after last frame and reset");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let mediaDescription2 = { let mediaDescription2 = {
"codec_mime": 'audio/mp4a-latm', "codec_mime": 'audio/mp4a-latm',
} }
let savepath = BASIC_PATH + '0000.es'; let savepath = BASIC_PATH + '0000.aac';
needgetMediaDes = true; needgetMediaDes = true;
workdoneAtEOS = true; workdoneAtEOS = true;
await media.getMediaCapability().then((mediaCaps) => { await media.getMediaCapability().then((mediaCaps) => {
...@@ -369,11 +370,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -369,11 +370,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0100', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0100', 0, async function (done) {
console.info("case test set EOS manually before last frame and reset"); console.info("case test set EOS manually before last frame and reset");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0100.es'; let savepath = BASIC_PATH + '0100.aac';
eosframenum = 500; eosframenum = 500;
workdoneAtEOS = true; workdoneAtEOS = true;
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
...@@ -408,11 +409,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -408,11 +409,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0200', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0200', 0, async function (done) {
console.info("case test flush at running state"); console.info("case test flush at running state");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0200.es'; let savepath = BASIC_PATH + '0200.aac';
workdoneAtEOS = true; workdoneAtEOS = true;
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success"); console.info("case create createAudioEncoder success");
...@@ -453,11 +454,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -453,11 +454,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0300', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0300', 0, async function (done) {
console.info("case test flush at EOS state"); console.info("case test flush at EOS state");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0300.es'; let savepath = BASIC_PATH + '0300.aac';
eosframenum = 500; eosframenum = 500;
flushAtEOS = true; flushAtEOS = true;
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
...@@ -492,11 +493,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -492,11 +493,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0400', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0400', 0, async function (done) {
console.info("case test stop at running state and reset"); console.info("case test stop at running state and reset");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0400.es'; let savepath = BASIC_PATH + '0400.aac';
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success"); console.info("case create createAudioEncoder success");
audioEncodeProcessor = processor; audioEncodeProcessor = processor;
...@@ -542,11 +543,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -542,11 +543,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0500', 0, async function (done) {
console.info("case test stop and restart"); console.info("case test stop and restart");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0500.es'; let savepath = BASIC_PATH + '0500.aac';
eosframenum = 100; eosframenum = 100;
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success"); console.info("case create createAudioEncoder success");
...@@ -596,11 +597,11 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -596,11 +597,11 @@ describe('AudioEncoderFuncPromise', function () {
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0600', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_PROMISE_01_0600', 0, async function (done) {
console.info("case test reconfigure for new file with the same format"); console.info("case test reconfigure for new file with the same format");
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
let savepath = BASIC_PATH + '0600.es'; let savepath = BASIC_PATH + '0600.aac';
eosframenum = 100; eosframenum = 100;
resetAtEOS = true; resetAtEOS = true;
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
...@@ -623,9 +624,9 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -623,9 +624,9 @@ describe('AudioEncoderFuncPromise', function () {
console.info("case start success"); console.info("case start success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
let mediaDescription2 = { let mediaDescription2 = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
} }
await sleep(10000).then(() => { await sleep(10000).then(() => {
console.info("start configure 2"); console.info("start configure 2");
...@@ -633,9 +634,9 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -633,9 +634,9 @@ describe('AudioEncoderFuncPromise', function () {
await audioEncodeProcessor.configure(mediaDescription2).then(() => { await audioEncodeProcessor.configure(mediaDescription2).then(() => {
console.info("configure 2 success"); console.info("configure 2 success");
resetParam(); resetParam();
readFile(AUDIOPATH2); readFile(AUDIOPATH);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
let savepath2 = BASIC_PATH + '0601.es'; let savepath2 = BASIC_PATH + '0601.aac';
workdoneAtEOS = true; workdoneAtEOS = true;
setCallback(savepath2, done); setCallback(savepath2, done);
await audioEncodeProcessor.prepare().then(() => { await audioEncodeProcessor.prepare().then(() => {
......
...@@ -19,7 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -19,7 +19,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('AudioEncoderFuncPromise', function () { describe('AudioEncoderFuncPromise', function () {
const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/' const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/'
const AUDIOPATH = RESOURCEPATH + 'S32LE.pcm'; const AUDIOPATH = RESOURCEPATH + 'S16LE.pcm';
let readStreamSync; let readStreamSync;
let eosframenum = 0; let eosframenum = 0;
let stopAtEOS = false; let stopAtEOS = false;
...@@ -35,7 +35,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -35,7 +35,7 @@ describe('AudioEncoderFuncPromise', function () {
let inputQueue = []; let inputQueue = [];
let outputQueue = []; let outputQueue = [];
const ES = [0, 4096]; const ES = [0, 4096];
let ES_LENGTH = 2000; let ES_LENGTH = 1500;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -57,7 +57,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -57,7 +57,7 @@ describe('AudioEncoderFuncPromise', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
ES_LENGTH = 2000; ES_LENGTH = 1500;
}) })
afterEach(function() { afterEach(function() {
...@@ -140,8 +140,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -140,8 +140,8 @@ describe('AudioEncoderFuncPromise', function () {
console.info("start add ADTS to Packet"); console.info("start add ADTS to Packet");
let packetLen = len + 7; // 7: head length let packetLen = len + 7; // 7: head length
let profile = 2; // 2: AAC LC let profile = 2; // 2: AAC LC
let freqIdx = 3; // 3: 48000HZ let freqIdx = 4; // 4: 44100HZ
let chanCfg = 1; // 1: 1 channel let chanCfg = 2; // 2: 2 channel
view[0] = 0xFF; view[0] = 0xFF;
view[1] = 0xF9; view[1] = 0xF9;
view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2); view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2);
...@@ -159,9 +159,12 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -159,9 +159,12 @@ describe('AudioEncoderFuncPromise', function () {
async function resetWork(audioEncodeProcessor) { async function resetWork(audioEncodeProcessor) {
resetParam(); resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(async() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
await audioEncodeProcessor.release().then(() => {
console.info("case release success");
}, failCallback).catch(failCatch);
audioEncodeProcessor = null; audioEncodeProcessor = null;
} }
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -309,8 +312,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -309,8 +312,8 @@ describe('AudioEncoderFuncPromise', function () {
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
await array[j].release().then(() => { await array[j].release().then(() => {
console.info("case release success"); console.info("case release success");
array[j] = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
array[j] = null;
} }
done(); done();
}) })
......
...@@ -17,9 +17,9 @@ import media from '@ohos.multimedia.media' ...@@ -17,9 +17,9 @@ import media from '@ohos.multimedia.media'
import Fileio from '@ohos.fileio' import Fileio from '@ohos.fileio'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioEncoderSTTCallback', function () { describe('AudioEncoderReliabilityCallback', function () {
const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/' const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/'
const AUDIOPATH = RESOURCEPATH + 'S32LE.pcm'; const AUDIOPATH = RESOURCEPATH + 'S16LE.pcm';
const BASIC_PATH = RESOURCEPATH + 'results/encode_reliability_callback_'; const BASIC_PATH = RESOURCEPATH + 'results/encode_reliability_callback_';
const END = 0; const END = 0;
const CONFIGURE = 1; const CONFIGURE = 1;
...@@ -54,9 +54,9 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -54,9 +54,9 @@ describe('AudioEncoderSTTCallback', function () {
let ES_LENGTH = 200; let ES_LENGTH = 200;
let mime = 'audio/mp4a-latm'; let mime = 'audio/mp4a-latm';
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
}; };
beforeAll(function() { beforeAll(function() {
...@@ -86,8 +86,8 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -86,8 +86,8 @@ describe('AudioEncoderSTTCallback', function () {
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
await audioEncodeProcessor.release().then(() => { await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success'); console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
audioEncodeProcessor = null;
} }
}) })
...@@ -165,8 +165,8 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -165,8 +165,8 @@ describe('AudioEncoderSTTCallback', function () {
console.info("start add ADTS to Packet"); console.info("start add ADTS to Packet");
let packetLen = len + 7; // 7: head length let packetLen = len + 7; // 7: head length
let profile = 2; // 2: AAC LC let profile = 2; // 2: AAC LC
let freqIdx = 3; // 3: 48000HZ let freqIdx = 4; // 4: 44100HZ
let chanCfg = 1; // 1: 1 channel let chanCfg = 2; // 2: 2 channel
view[0] = 0xFF; view[0] = 0xFF;
view[1] = 0xF9; view[1] = 0xF9;
view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2); view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2);
...@@ -386,9 +386,7 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -386,9 +386,7 @@ describe('AudioEncoderSTTCallback', function () {
} }
} }
else{ else{
writeHead(savepath, outputobject.length); console.info("not last frame, continue");
writeFile(savepath, outputobject.data, outputobject.length);
console.info("write to file success");
} }
audioEncodeProcessor.freeOutputBuffer(outputobject, () => { audioEncodeProcessor.freeOutputBuffer(outputobject, () => {
console.info('release output success'); console.info('release output success');
......
...@@ -17,9 +17,9 @@ import media from '@ohos.multimedia.media' ...@@ -17,9 +17,9 @@ import media from '@ohos.multimedia.media'
import Fileio from '@ohos.fileio' import Fileio from '@ohos.fileio'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('AudioEncoderSTTPromise', function () { describe('AudioEncoderReliabilityPromise', function () {
const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/' const RESOURCEPATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/'
const AUDIOPATH = RESOURCEPATH + 'S32LE.pcm'; const AUDIOPATH = RESOURCEPATH + 'S16LE.pcm';
const BASIC_PATH = RESOURCEPATH + 'results/encode_reliability_promise_'; const BASIC_PATH = RESOURCEPATH + 'results/encode_reliability_promise_';
const END = 0; const END = 0;
const CONFIGURE = 1; const CONFIGURE = 1;
...@@ -54,9 +54,9 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -54,9 +54,9 @@ describe('AudioEncoderSTTPromise', function () {
let ES_LENGTH = 200; let ES_LENGTH = 200;
let mime = 'audio/mp4a-latm'; let mime = 'audio/mp4a-latm';
let mediaDescription = { let mediaDescription = {
"channel_count": 1, "channel_count": 2,
"sample_rate": 48000, "sample_rate": 44100,
"audio_sample_format": 3, "audio_sample_format": 1,
}; };
let expectError = false; let expectError = false;
...@@ -88,8 +88,8 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -88,8 +88,8 @@ describe('AudioEncoderSTTPromise', function () {
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
await audioEncodeProcessor.release().then(() => { await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success'); console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
audioEncodeProcessor = null;
} }
}) })
...@@ -183,8 +183,8 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -183,8 +183,8 @@ describe('AudioEncoderSTTPromise', function () {
console.info("start add ADTS to Packet"); console.info("start add ADTS to Packet");
let packetLen = len + 7; // 7: head length let packetLen = len + 7; // 7: head length
let profile = 2; // 2: AAC LC let profile = 2; // 2: AAC LC
let freqIdx = 3; // 3: 48000HZ let freqIdx = 4; // 4: 44100HZ
let chanCfg = 1; // 1: 1 channel let chanCfg = 2; // 2: 2 channel
view[0] = 0xFF; view[0] = 0xFF;
view[1] = 0xF9; view[1] = 0xF9;
view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2); view[2] = ((profile - 1) << 6) + (freqIdx << 2) + (chanCfg >> 2);
...@@ -391,9 +391,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -391,9 +391,7 @@ describe('AudioEncoderSTTPromise', function () {
} }
} }
else{ else{
writeHead(savepath, outputobject.length); console.info("not last frame, continue");
writeFile(savepath, outputobject.data, outputobject.length);
console.info("write to file success");
} }
audioEncodeProcessor.freeOutputBuffer(outputobject).then(() => { audioEncodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success'); console.info('release output success');
......
...@@ -136,57 +136,50 @@ describe('VideoDecoderEnum', function () { ...@@ -136,57 +136,50 @@ describe('VideoDecoderEnum', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs(){ async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.info('in case: enqueueInputs in');
while (inputQueue.length > 0 && !inputEosFlag) { console.log('in case: inputObject.index: ' + inputObject.index);
let inputObject = inputQueue.shift(); if (frameCountIn < ES_FRAME_SIZE.length) {
console.log('in case: inputObject.index: ' + inputObject.index); getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.timeMs = timestamp;
getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]); inputObject.offset = 0;
inputObject.timeMs = timestamp; inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.offset = 0; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.length = ES_FRAME_SIZE[frameCountIn]; frameCountIn++;
console.info('in case: frameCountIn ' + frameCountIn); timestamp += 16.67;
frameCountIn++; }
timestamp += 16.67; if (isCodecData) {
} inputObject.flags = 8;
if (isCodecData) { isCodecData = false;
inputObject.flags = 8; timestamp = 0;
isCodecData = false; } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
timestamp = 0; inputObject.flags = 1;
} else if (frameCountIn >= ES_FRAME_SIZE.length - 1) { inputEosFlag = true;
inputObject.flags = 1; } else {
inputEosFlag = true; inputObject.flags = 4;
} else { }
inputObject.flags = 4; if (frameCountIn == ES_FRAME_SIZE.length / 2) {
} videoDecodeProcessor.setParameter({
if (frameCountIn == ES_FRAME_SIZE.length / 2) { 'bitrate': 6400,
videoDecodeProcessor.setParameter({ }).then(() => {
'bitrate': 6400, console.info('in case: setParameter success ');
}).then(() => {
console.info('in case: setParameter success ');
}, failCallback).catch(failCatch);
}
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
} }
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch);
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep){ async function dequeueOutputs(nextStep, outputObject){
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1) {
while (outputQueue.length > 0){ nextStep();
let outputObject = outputQueue.shift(); return;
if (outputObject.flags == 1) {
nextStep();
return;
}
frameCountOut++;
await videoDecodeProcessor.freeOutputBuffer(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
frameCountOut++;
await videoDecodeProcessor.freeOutputBuffer(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
function setCallback(nextStep){ function setCallback(nextStep){
...@@ -204,8 +197,7 @@ describe('VideoDecoderEnum', function () { ...@@ -204,8 +197,7 @@ describe('VideoDecoderEnum', function () {
console.info('in case: inputBufferAvailable inBuffer.flags: '+ inBuffer.flags); console.info('in case: inputBufferAvailable inBuffer.flags: '+ inBuffer.flags);
expect(inBuffer.timeMs !== undefined).assertTrue(); expect(inBuffer.timeMs !== undefined).assertTrue();
console.info('in case: inputBufferAvailable inBuffer.timeMs: '+ inBuffer.timeMs); console.info('in case: inputBufferAvailable inBuffer.timeMs: '+ inBuffer.timeMs);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
...@@ -213,8 +205,7 @@ describe('VideoDecoderEnum', function () { ...@@ -213,8 +205,7 @@ describe('VideoDecoderEnum', function () {
videoDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => { videoDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
console.info('get outputMediaDescription : ' + MediaDescription); console.info('get outputMediaDescription : ' + MediaDescription);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -177,74 +177,65 @@ describe('VideoDecoderFuncCallbackTest', function () { ...@@ -177,74 +177,65 @@ describe('VideoDecoderFuncCallbackTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs(){ async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.offset = 0; frameCountIn++;
inputObject.length = ES_FRAME_SIZE[frameCountIn]; timestamp += 16.67;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 16.67; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length - 1) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true; }
if (frameCountIn == ES_FRAME_SIZE.length / 2) {
videoDecodeProcessor.setParameter({
'bitrate': 6400,
}, (err) => {
expect(err).assertUndefined();
console.info('in case: setParameter success ');
});
}
videoDecodeProcessor.pushInputData(inputObject, (err) => {
if (typeof (err) == 'undefined') {
console.info('in case: queueInput success ');
} else { } else {
inputObject.flags = 4; console.info(`in case queueInput err called,errMessage is ${error.message}`);
} }
if (frameCountIn == ES_FRAME_SIZE.length / 2) { })
videoDecodeProcessor.setParameter({
'bitrate': 6400,
}, (err) => {
expect(err).assertUndefined();
console.info('in case: setParameter success ');
});
}
videoDecodeProcessor.pushInputData(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 */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep){ async function dequeueOutputs(nextStep, outputObject){
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ nextStep();
let outputObject = outputQueue.shift(); return;
if (outputObject.flags == 1 ) {
nextStep();
return;
}
frameCountOut++;
videoDecodeProcessor.renderOutputData(outputObject, (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}`);
}
})
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject, (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){ function setCallback(nextStep){
console.info('in case: setCallback in'); console.info('in case: setCallback in');
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
...@@ -253,8 +244,7 @@ describe('VideoDecoderFuncCallbackTest', function () { ...@@ -253,8 +244,7 @@ describe('VideoDecoderFuncCallbackTest', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info('get outputMediaDescription : ' + MediaDescription); console.info('get outputMediaDescription : ' + MediaDescription);
}); });
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -188,65 +188,56 @@ describe('VideoDecoderFuncPromiseTest', function () { ...@@ -188,65 +188,56 @@ describe('VideoDecoderFuncPromiseTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs(){ async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.offset = 0; frameCountIn++;
inputObject.length = ES_FRAME_SIZE[frameCountIn]; timestamp += 16.67;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 16.67; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length - 1) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true; }
} else { if (frameCountIn == ES_FRAME_SIZE.length / 2) {
inputObject.flags = 4; videoDecodeProcessor.setParameter({
} 'bitrate': 6400,
if (frameCountIn == ES_FRAME_SIZE.length / 2) { }).then(() => {
videoDecodeProcessor.setParameter({ console.info('in case: setParameter success ');
'bitrate': 6400,
}).then(() => {
console.info('in case: setParameter success ');
}, failCallback).catch(failCatch);
}
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
} }
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch);
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep){ async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1) {
while (outputQueue.length > 0){ nextStep();
let outputObject = outputQueue.shift(); return;
if (outputObject.flags == 1) {
nextStep();
return;
}
frameCountOut++;
await videoDecodeProcessor.renderOutputData(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
frameCountOut++;
await videoDecodeProcessor.freeOutputBuffer(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
function setCallback(nextStep){ function setCallback(nextStep){
console.info('in case: setCallback in'); console.info('in case: setCallback in');
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
...@@ -254,8 +245,7 @@ describe('VideoDecoderFuncPromiseTest', function () { ...@@ -254,8 +245,7 @@ describe('VideoDecoderFuncPromiseTest', function () {
videoDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => { videoDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => {
console.info('get outputMediaDescription : ' + MediaDescription); console.info('get outputMediaDescription : ' + MediaDescription);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -172,53 +172,45 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -172,53 +172,45 @@ describe('VideoDecoderReliCallbackTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs() { async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; position = position + ES_FRAME_SIZE[frameCountIn];
inputObject.offset = 0; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.length = ES_FRAME_SIZE[frameCountIn]; frameCountIn++;
position = position + ES_FRAME_SIZE[frameCountIn]; timestamp += 1000 / mediaDescription.frame_rate;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 1000 / mediaDescription.frame_rate; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true;
} else {
inputObject.flags = 4;
}
videoDecodeProcessor.pushInputData(inputObject, (err) => {
console.info('in case: queueInput success ');
})
} }
videoDecodeProcessor.pushInputData(inputObject, (err) => {
console.info('in case: queueInput success ');
})
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep) { async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ if (workdoneAtEOS) {
let outputObject = outputQueue.shift(); doneWork(nextStep);
if (outputObject.flags == 1 ) {
if (workdoneAtEOS) {
doneWork(nextStep);
}
return;
} }
frameCountOut++; return;
videoDecodeProcessor.renderOutputData(outputObject, () => {
console.log('in case: release output count:' + frameCountOut);
})
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject, () => {
console.log('in case: release output count:' + frameCountOut);
})
} }
function toConfigure(mySteps, done, expectFail) { function toConfigure(mySteps, done, expectFail) {
...@@ -399,14 +391,12 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -399,14 +391,12 @@ describe('VideoDecoderReliCallbackTest', function () {
function setCallback(nextStep){ function setCallback(nextStep){
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -177,55 +177,47 @@ describe('VideoDecoderReliPromiseTest', function () { ...@@ -177,55 +177,47 @@ describe('VideoDecoderReliPromiseTest', function () {
} }
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs() { async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; position = position + ES_FRAME_SIZE[frameCountIn];
inputObject.offset = 0; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.length = ES_FRAME_SIZE[frameCountIn]; frameCountIn++;
position = position + ES_FRAME_SIZE[frameCountIn]; timestamp += 1000 / mediaDescription.frame_rate;
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.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, caseCallback).catch(failCatch);
} }
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.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, caseCallback).catch(failCatch);
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep) { async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ if (workdoneAtEOS) {
let outputObject = outputQueue.shift(); await doneWork();
if (outputObject.flags == 1 ) { nextStep();
if (workdoneAtEOS) {
await doneWork();
nextStep();
}
return;
} }
frameCountOut++; return;
videoDecodeProcessor.renderOutputData(outputObject).then(() => {
console.info('in case: release output success');
console.log('in case: release output count:' + frameCountOut);
}, caseCallback).catch(failCatch);
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject).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) { function toConfigure(mySteps, done, failureCallback, catchCallback) {
...@@ -396,14 +388,12 @@ describe('VideoDecoderReliPromiseTest', function () { ...@@ -396,14 +388,12 @@ describe('VideoDecoderReliPromiseTest', function () {
function setCallback(nextStep){ function setCallback(nextStep){
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -189,73 +189,63 @@ describe('VideoDecoderFuncCallbackTest', function () { ...@@ -189,73 +189,63 @@ describe('VideoDecoderFuncCallbackTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs(){ async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.offset = 0; frameCountIn++;
inputObject.length = ES_FRAME_SIZE[frameCountIn]; timestamp += 16.67;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 16.67; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length - 1) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true; }
videoDecodeProcessor.pushInputData(inputObject, (err) => {
if (typeof (err) == 'undefined') {
console.info('in case: queueInput success ');
} else { } else {
inputObject.flags = 4; console.info(`in case queueInput err called,errMessage is ${error.message}`);
} }
videoDecodeProcessor.pushInputData(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 */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep){ async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ nextStep();
let outputObject = outputQueue.shift(); return;
if (outputObject.flags == 1 ) {
nextStep();
return;
}
frameCountOut++;
videoDecodeProcessor.renderOutputData(outputObject, (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}`);
}
})
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject, (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){ function setCallback(nextStep){
console.info('in case: setCallback in'); console.info('in case: setCallback in');
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -191,64 +191,54 @@ describe('VideoDecoderFuncPromiseTest', function () { ...@@ -191,64 +191,54 @@ describe('VideoDecoderFuncPromiseTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs(){ async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.offset = 0; frameCountIn++;
inputObject.length = ES_FRAME_SIZE[frameCountIn]; timestamp += 16.67;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 16.67; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length - 1) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length - 1) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true;
} else {
inputObject.flags = 4;
}
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch);
} }
videoDecodeProcessor.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, failCallback).catch(failCatch);
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep){ async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1) {
while (outputQueue.length > 0){ nextStep();
let outputObject = outputQueue.shift(); return;
if (outputObject.flags == 1) {
nextStep();
return;
}
frameCountOut++;
await videoDecodeProcessor.renderOutputData(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
frameCountOut++;
await videoDecodeProcessor.freeOutputBuffer(outputObject).then(() => {
console.log('in case: release output count:' + frameCountOut);
}, failCallback).catch(failCatch);
} }
function setCallback(nextStep){ function setCallback(nextStep){
console.info('in case: setCallback in'); console.info('in case: setCallback in');
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -172,53 +172,45 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () { ...@@ -172,53 +172,45 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs() { async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; position = position + ES_FRAME_SIZE[frameCountIn];
inputObject.offset = 0; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.length = ES_FRAME_SIZE[frameCountIn]; frameCountIn++;
position = position + ES_FRAME_SIZE[frameCountIn]; timestamp += 1000 / mediaDescription.frame_rate;
console.info('in case: frameCountIn ' + frameCountIn); }
frameCountIn++; if (isCodecData) {
timestamp += 1000 / mediaDescription.frame_rate; inputObject.flags = 8;
} isCodecData = false;
if (isCodecData) { timestamp = 0;
inputObject.flags = 8; } else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) {
isCodecData = false; inputObject.flags = 1;
timestamp = 0; inputEosFlag = true;
} else if (frameCountIn >= ES_FRAME_SIZE.length || frameCountIn == eosFrameId) { } else {
inputObject.flags = 1; inputObject.flags = 4;
inputEosFlag = true;
} else {
inputObject.flags = 4;
}
videoDecodeProcessor.pushInputData(inputObject, (err) => {
console.info('in case: queueInput success ');
})
} }
videoDecodeProcessor.pushInputData(inputObject, (err) => {
console.info('in case: queueInput success ');
})
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep) { async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ if (workdoneAtEOS) {
let outputObject = outputQueue.shift(); doneWork(nextStep);
if (outputObject.flags == 1 ) {
if (workdoneAtEOS) {
doneWork(nextStep);
}
return;
} }
frameCountOut++; return;
videoDecodeProcessor.renderOutputData(outputObject, () => {
console.log('in case: release output count:' + frameCountOut);
})
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject, () => {
console.log('in case: release output count:' + frameCountOut);
})
} }
function toConfigure(mySteps, done, expectFail) { function toConfigure(mySteps, done, expectFail) {
...@@ -400,14 +392,12 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () { ...@@ -400,14 +392,12 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
function setCallback(nextStep){ function setCallback(nextStep){
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
...@@ -179,55 +179,47 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () { ...@@ -179,55 +179,47 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
} }
/* push inputbuffers into codec */ /* push inputbuffers into codec */
async function enqueueInputs() { async function enqueueInputs(inputObject) {
console.info('in case: enqueueInputs in'); console.log('in case: inputObject.index: ' + inputObject.index);
while (inputQueue.length > 0 && !inputEosFlag) { if (frameCountIn < ES_FRAME_SIZE.length) {
let inputObject = inputQueue.shift(); getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]);
console.log('in case: inputObject.index: ' + inputObject.index); inputObject.timeMs = timestamp;
if (frameCountIn < ES_FRAME_SIZE.length) { inputObject.offset = 0;
getContent(inputObject.data, position, ES_FRAME_SIZE[frameCountIn]); inputObject.length = ES_FRAME_SIZE[frameCountIn];
inputObject.timeMs = timestamp; position = position + ES_FRAME_SIZE[frameCountIn];
inputObject.offset = 0; console.info('in case: frameCountIn ' + frameCountIn);
inputObject.length = ES_FRAME_SIZE[frameCountIn]; frameCountIn++;
position = position + ES_FRAME_SIZE[frameCountIn]; timestamp += 1000 / mediaDescription.frame_rate;
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.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, caseCallback).catch(failCatch);
} }
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.pushInputData(inputObject).then(() => {
console.info('in case: queueInput success ');
}, caseCallback).catch(failCatch);
} }
/* get outputbuffers from codec */ /* get outputbuffers from codec */
async function dequeueOutputs(nextStep) { async function dequeueOutputs(nextStep, outputObject) {
console.log('outputQueue.length:' + outputQueue.length); if (outputObject.flags == 1 ) {
while (outputQueue.length > 0){ if (workdoneAtEOS) {
let outputObject = outputQueue.shift(); await doneWork();
if (outputObject.flags == 1 ) { nextStep();
if (workdoneAtEOS) {
await doneWork();
nextStep();
}
return;
} }
frameCountOut++; return;
videoDecodeProcessor.renderOutputData(outputObject).then(() => {
console.info('in case: release output success');
console.log('in case: release output count:' + frameCountOut);
}, caseCallback).catch(failCatch);
} }
frameCountOut++;
videoDecodeProcessor.freeOutputBuffer(outputObject).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) { function toConfigure(mySteps, done, failureCallback, catchCallback) {
...@@ -399,14 +391,12 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () { ...@@ -399,14 +391,12 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
function setCallback(nextStep){ function setCallback(nextStep){
videoDecodeProcessor.on('needInputData', async (inBuffer) => { videoDecodeProcessor.on('needInputData', async (inBuffer) => {
console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index); console.info('in case: inputBufferAvailable inBuffer.index: '+ inBuffer.index);
inputQueue.push(inBuffer); enqueueInputs(inBuffer);
await enqueueInputs();
}); });
videoDecodeProcessor.on('newOutputData', async (outBuffer) => { videoDecodeProcessor.on('newOutputData', async (outBuffer) => {
console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index); console.info('in case: outputBufferAvailable outBuffer.index: '+ outBuffer.index);
outputQueue.push(outBuffer); dequeueOutputs(nextStep, outBuffer);
await dequeueOutputs(nextStep);
}); });
videoDecodeProcessor.on('error',(err) => { videoDecodeProcessor.on('error',(err) => {
......
{ {
"description": "Configuration for videoPlayer Tests", "description": "Configuration for videoEncoder Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "2000000", "test-timeout": "2000000",
......
...@@ -56,12 +56,6 @@ describe('videoEncoderSoftwareMultiInstances', function () { ...@@ -56,12 +56,6 @@ describe('videoEncoderSoftwareMultiInstances', function () {
afterEach(async function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (videoEncodeProcessor != null){
await videoEncodeProcessor.release().then(() => {
console.info("case release success");
videoEncodeProcessor = null;
}, failCallback).catch(failCatch);
}
}) })
afterAll(function() { afterAll(function() {
...@@ -255,8 +249,8 @@ describe('videoEncoderSoftwareMultiInstances', function () { ...@@ -255,8 +249,8 @@ describe('videoEncoderSoftwareMultiInstances', function () {
async function toRelease() { async function toRelease() {
await videoEncodeProcessor.release().then(() => { await videoEncodeProcessor.release().then(() => {
console.info("case release success"); console.info("case release success");
videoEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
videoEncodeProcessor = null;
} }
...@@ -287,10 +281,10 @@ describe('videoEncoderSoftwareMultiInstances', function () { ...@@ -287,10 +281,10 @@ describe('videoEncoderSoftwareMultiInstances', function () {
for (let j = 1; j < 3; j++) { for (let j = 1; j < 3; j++) {
await array[j].release().then(() => { await array[j].release().then(() => {
console.info("case release encoder " + j); console.info("case release encoder " + j);
array[j] = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
array[j] = null;
} }
console.info('release 16 encoders success'); console.info('release encoders success');
done(); done();
}); });
async function runCase() { async function runCase() {
......
...@@ -38,8 +38,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { ...@@ -38,8 +38,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
beforeEach(function() { beforeEach(async function() {
console.info('beforeEach case'); console.info('beforeEach case');
await msleep(1000).then(() => {
}, failCallback).catch(failCatch);
videoEncodeProcessor = null; videoEncodeProcessor = null;
mediaTest = null; mediaTest = null;
surfaceID = ''; surfaceID = '';
...@@ -74,6 +76,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { ...@@ -74,6 +76,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () {
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
} }
function msleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function writeFile(path, buf, len){ function writeFile(path, buf, len){
try { try {
let writestream = Fileio.createStreamSync(path, 'ab+'); let writestream = Fileio.createStreamSync(path, 'ab+');
......
...@@ -37,8 +37,10 @@ describe('videoSoftwareEncoderFuncPromise', function () { ...@@ -37,8 +37,10 @@ describe('videoSoftwareEncoderFuncPromise', function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
beforeEach(function() { beforeEach(async function() {
console.info('beforeEach case'); console.info('beforeEach case');
await msleep(1000).then(() => {
}, failCallback).catch(failCatch);
videoEncodeProcessor = null; videoEncodeProcessor = null;
mediaTest = null; mediaTest = null;
surfaceID = ''; surfaceID = '';
...@@ -76,6 +78,10 @@ describe('videoSoftwareEncoderFuncPromise', function () { ...@@ -76,6 +78,10 @@ describe('videoSoftwareEncoderFuncPromise', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
} }
function msleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function resetParam() { function resetParam() {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
......
...@@ -64,6 +64,8 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -64,6 +64,8 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
beforeEach(async function() { beforeEach(async function() {
console.info('beforeEach case'); console.info('beforeEach case');
await msleep(1000).then(() => {
}, failCallback).catch(failCatch);
videoEncodeProcessor = null; videoEncodeProcessor = null;
mediaTest = null; mediaTest = null;
surfaceID = ''; surfaceID = '';
...@@ -98,6 +100,11 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -98,6 +100,11 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
console.error(`in case error failCatch called,errMessage is ${err.message}`); console.error(`in case error failCatch called,errMessage is ${err.message}`);
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
} }
function msleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function printError(err, expectFail) { function printError(err, expectFail) {
expect((err != undefined) == expectFail).assertTrue(); expect((err != undefined) == expectFail).assertTrue();
if (expectFail == false && err != undefined) { if (expectFail == false && err != undefined) {
...@@ -105,6 +112,7 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -105,6 +112,7 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
console.error(`in case error failCatch called,errMessage is ${err.message}`); console.error(`in case error failCatch called,errMessage is ${err.message}`);
} }
} }
function writeFile(path, buf, len){ function writeFile(path, buf, len){
try { try {
let writestream = Fileio.createStreamSync(path, 'ab+'); let writestream = Fileio.createStreamSync(path, 'ab+');
......
...@@ -65,8 +65,10 @@ describe('videoEncoderReliabilityPromise', function () { ...@@ -65,8 +65,10 @@ describe('videoEncoderReliabilityPromise', function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
beforeEach(function() { beforeEach(async function() {
console.info('beforeEach case'); console.info('beforeEach case');
await msleep(1000).then(() => {
}, failCallback).catch(failCatch);
videoEncodeProcessor = null; videoEncodeProcessor = null;
surfaceID = ''; surfaceID = '';
outputQueue = []; outputQueue = [];
...@@ -86,8 +88,8 @@ describe('videoEncoderReliabilityPromise', function () { ...@@ -86,8 +88,8 @@ describe('videoEncoderReliabilityPromise', function () {
if (videoEncodeProcessor != null) { if (videoEncodeProcessor != null) {
await videoEncodeProcessor.release().then(() => { await videoEncodeProcessor.release().then(() => {
console.info(`case release 1`); console.info(`case release 1`);
videoEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
videoEncodeProcessor = null;
} }
}) })
...@@ -111,6 +113,10 @@ describe('videoEncoderReliabilityPromise', function () { ...@@ -111,6 +113,10 @@ describe('videoEncoderReliabilityPromise', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
} }
function msleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function resetParam() { function resetParam() {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
...@@ -1353,7 +1359,7 @@ describe('videoEncoderReliabilityPromise', function () { ...@@ -1353,7 +1359,7 @@ describe('videoEncoderReliabilityPromise', function () {
it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_EOS_PROMISE_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'eos_0500.es'; let savepath = BASIC_PATH + 'eos_0500.es';
let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON, let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, START, STARTSTREAM, HOLDON,
JUDGE_EOS, STOP, START, STOP, STOPSTREAM, END); JUDGE_EOS, STOP, START, STOP, STOPSTREAM, RELEASE, END);
frameTotal = 2; frameTotal = 2;
createVideoEncoder(savepath, mySteps, done); createVideoEncoder(savepath, mySteps, done);
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册