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

!4770 修改编解码用例匹配codec状态机修改

Merge pull request !4770 from ling990/ling990
...@@ -139,6 +139,7 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -139,6 +139,7 @@ describe('AudioDecoderFuncCallback', function () {
let outputCnt = 0; let outputCnt = 0;
let inputCnt = 0; let inputCnt = 0;
let frameThreshold = 10; let frameThreshold = 10;
let lockFlag = false;
beforeAll(async function() { beforeAll(async function() {
console.info('beforeAll case 1'); console.info('beforeAll case 1');
...@@ -254,6 +255,7 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -254,6 +255,7 @@ describe('AudioDecoderFuncCallback', function () {
ES_LENGTH = 1500; ES_LENGTH = 1500;
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -288,6 +290,7 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -288,6 +290,7 @@ describe('AudioDecoderFuncCallback', function () {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
} }
async function getFdRead(readPath, done) { async function getFdRead(readPath, done) {
...@@ -345,6 +348,7 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -345,6 +348,7 @@ describe('AudioDecoderFuncCallback', function () {
} }
async function flushWork(done) { async function flushWork(done) {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
await getFdRead(readpath, done); await getFdRead(readpath, done);
...@@ -353,6 +357,11 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -353,6 +357,11 @@ describe('AudioDecoderFuncCallback', function () {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
workdoneAtEOS =true; workdoneAtEOS =true;
lockFlag = false;
audioDecodeProcessor.start((err) => {
expect(err).assertUndefined();
console.info("case start after flush success");
});
}) })
} }
...@@ -403,12 +412,14 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -403,12 +412,14 @@ describe('AudioDecoderFuncCallback', function () {
} }
timestamp += ES[frameCnt]/samplerate; timestamp += ES[frameCnt]/samplerate;
frameCnt += 1; frameCnt += 1;
if (!lockFlag) {
audioDecodeProcessor.pushInputData(inputobject, () => { audioDecodeProcessor.pushInputData(inputobject, () => {
console.info('queueInput success'); console.info('queueInput success');
inputCnt += 1; inputCnt += 1;
}) })
} }
} }
}
async function dequeueAllOutputs(queue, savepath, done) { async function dequeueAllOutputs(queue, savepath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -431,11 +442,13 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -431,11 +442,13 @@ describe('AudioDecoderFuncCallback', function () {
else{ else{
console.info("write to file success"); console.info("write to file success");
} }
if (!lockFlag) {
audioDecodeProcessor.freeOutputBuffer(outputobject, () => { audioDecodeProcessor.freeOutputBuffer(outputobject, () => {
console.info('release output success'); console.info('release output success');
}) })
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -677,12 +690,18 @@ describe('AudioDecoderFuncCallback', function () { ...@@ -677,12 +690,18 @@ describe('AudioDecoderFuncCallback', function () {
}) })
}); });
eventEmitter.on('flush', () => { eventEmitter.on('flush', () => {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioDecodeProcessor.flush((err) => { audioDecodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush after 2s success`); console.info(`case flush after 2s success`);
}) lockFlag = false;
audioDecodeProcessor.start((err) => {
expect(err).assertUndefined();
console.info(`case start after flush success`);
});
});
}); });
media.createAudioDecoderByMime('audio/mp4a-latm', (err, processor) => { media.createAudioDecoderByMime('audio/mp4a-latm', (err, processor) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
......
...@@ -138,6 +138,7 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -138,6 +138,7 @@ describe('AudioDecoderFuncPromise', function () {
let outputCnt = 0; let outputCnt = 0;
let inputCnt = 0; let inputCnt = 0;
let frameThreshold = 10; let frameThreshold = 10;
let lockFlag = false;
beforeAll(async function() { beforeAll(async function() {
...@@ -254,6 +255,7 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -254,6 +255,7 @@ describe('AudioDecoderFuncPromise', function () {
ES_LENGTH = 1500; ES_LENGTH = 1500;
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -298,6 +300,7 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -298,6 +300,7 @@ describe('AudioDecoderFuncPromise', function () {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
} }
async function getFdRead(readPath, done) { async function getFdRead(readPath, done) {
...@@ -349,6 +352,7 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -349,6 +352,7 @@ describe('AudioDecoderFuncPromise', function () {
} }
async function flushWork(done) { async function flushWork(done) {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
await getFdRead(readpath, done); await getFdRead(readpath, done);
...@@ -357,6 +361,12 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -357,6 +361,12 @@ describe('AudioDecoderFuncPromise', function () {
resetParam(); resetParam();
workdoneAtEOS =true; workdoneAtEOS =true;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
lockFlag = false;
await audioDecodeProcessor.start().then(() => {
console.info("case start after flush success");
resetParam();
workdoneAtEOS =true;
}, failCallback).catch(failCatch);
} }
async function doneWork() { async function doneWork() {
...@@ -399,12 +409,14 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -399,12 +409,14 @@ describe('AudioDecoderFuncPromise', function () {
} }
timestamp += ES[frameCnt]/samplerate; timestamp += ES[frameCnt]/samplerate;
frameCnt += 1; frameCnt += 1;
if (!lockFlag) {
audioDecodeProcessor.pushInputData(inputobject).then(() => { audioDecodeProcessor.pushInputData(inputobject).then(() => {
console.info('case queueInput success'); console.info('case queueInput success');
inputCnt += 1; inputCnt += 1;
}); });
} }
} }
}
async function dequeueAllOutputs(queue, savapath, done) { async function dequeueAllOutputs(queue, savapath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -430,11 +442,13 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -430,11 +442,13 @@ describe('AudioDecoderFuncPromise', function () {
else{ else{
console.info("write to file success"); console.info("write to file success");
} }
if (!lockFlag) {
audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => { audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success'); console.info('release output success');
}); });
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -605,12 +619,17 @@ describe('AudioDecoderFuncPromise', function () { ...@@ -605,12 +619,17 @@ describe('AudioDecoderFuncPromise', function () {
await audioDecodeProcessor.start().then(() => { await audioDecodeProcessor.start().then(() => {
console.info("case start success"); console.info("case start success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
await sleep(500).then(() => { await sleep(500).then(async() => {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioDecodeProcessor.flush().then(() => { await audioDecodeProcessor.flush().then(() => {
console.info("case flush after 5s"); console.info("case flush after 5s");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
lockFlag = false;
await audioDecodeProcessor.start().then(() => {
console.info("case start after flush success");
}, failCallback).catch(failCatch);
}) })
}) })
......
...@@ -147,6 +147,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -147,6 +147,7 @@ describe('AudioDecoderReliabilityCallback', function () {
"audio_sample_format": 1, "audio_sample_format": 1,
}; };
let fdRead; let fdRead;
let lockFlag = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -257,6 +258,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -257,6 +258,7 @@ describe('AudioDecoderReliabilityCallback', function () {
381, 410, 394, 386, 345, 345, 354, 397, 386, 375, 390, 347, 411, 381, 383, 374, 379, 381, 410, 394, 386, 345, 345, 354, 397, 386, 375, 390, 347, 411, 381, 383, 374, 379,
380, 378, 391, 380, 339, 390, 383, 375]; 380, 378, 391, 380, 339, 390, 383, 375];
ES_LENGTH = 500; ES_LENGTH = 500;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -287,6 +289,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -287,6 +289,7 @@ describe('AudioDecoderReliabilityCallback', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
lockFlag = false;
} }
async function createAudioDecoder(savepath, mySteps, done) { async function createAudioDecoder(savepath, mySteps, done) {
...@@ -399,6 +402,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -399,6 +402,7 @@ describe('AudioDecoderReliabilityCallback', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioDecodeProcessor.flush(async(err) => { audioDecodeProcessor.flush(async(err) => {
...@@ -410,6 +414,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -410,6 +414,7 @@ describe('AudioDecoderReliabilityCallback', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
lockFlag = false;
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, mediaDescription, done);
}); });
break; break;
...@@ -518,11 +523,13 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -518,11 +523,13 @@ describe('AudioDecoderReliabilityCallback', function () {
} }
timestamp += ES[frameCnt]/samplerate; timestamp += ES[frameCnt]/samplerate;
frameCnt += 1; frameCnt += 1;
if (!lockFlag) {
audioDecodeProcessor.pushInputData(inputobject, () => { audioDecodeProcessor.pushInputData(inputobject, () => {
console.info('queueInput success'); console.info('queueInput success');
}) })
} }
} }
}
async function dequeueAllOutputs(queue, savepath, done) { async function dequeueAllOutputs(queue, savepath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -538,11 +545,13 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -538,11 +545,13 @@ describe('AudioDecoderReliabilityCallback', function () {
else{ else{
console.info("not last frame, continue"); console.info("not last frame, continue");
} }
if (!lockFlag) {
audioDecodeProcessor.freeOutputBuffer(outputobject, () => { audioDecodeProcessor.freeOutputBuffer(outputobject, () => {
console.info('release output success'); console.info('release output success');
}) })
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -879,7 +888,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -879,7 +888,7 @@ describe('AudioDecoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'start_0500.pcm'; let savepath = BASIC_PATH + 'start_0500.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, END);
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -979,7 +988,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -979,7 +988,7 @@ describe('AudioDecoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0400', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0400.pcm'; let savepath = BASIC_PATH + 'flush_0400.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -994,7 +1003,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -994,7 +1003,7 @@ describe('AudioDecoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0500.pcm'; let savepath = BASIC_PATH + 'flush_0500.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -1023,7 +1032,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -1023,7 +1032,7 @@ describe('AudioDecoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0700', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0700', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0700.pcm'; let savepath = BASIC_PATH + 'flush_0700.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, END); let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, START, END);
EOSFrameNum = 2; EOSFrameNum = 2;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
......
...@@ -149,6 +149,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -149,6 +149,7 @@ describe('AudioDecoderReliabilityPromise', function () {
}; };
let expectError = false; let expectError = false;
let fdRead; let fdRead;
let lockFlag = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -261,6 +262,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -261,6 +262,7 @@ describe('AudioDecoderReliabilityPromise', function () {
380, 378, 391, 380, 339, 390, 383, 375]; 380, 378, 391, 380, 339, 390, 383, 375];
ES_LENGTH = 500; ES_LENGTH = 500;
expectError = false; expectError = false;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -308,6 +310,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -308,6 +310,7 @@ describe('AudioDecoderReliabilityPromise', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
lockFlag = false;
} }
async function createAudioDecoder(savepath, mySteps, done) { async function createAudioDecoder(savepath, mySteps, done) {
...@@ -416,6 +419,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -416,6 +419,7 @@ describe('AudioDecoderReliabilityPromise', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioDecodeProcessor.flush().then(async() => { audioDecodeProcessor.flush().then(async() => {
...@@ -426,6 +430,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -426,6 +430,7 @@ describe('AudioDecoderReliabilityPromise', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
lockFlag = false;
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
...@@ -525,11 +530,13 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -525,11 +530,13 @@ describe('AudioDecoderReliabilityPromise', function () {
} }
timestamp += ES[frameCnt]/samplerate; timestamp += ES[frameCnt]/samplerate;
frameCnt += 1; frameCnt += 1;
if (!lockFlag) {
audioDecodeProcessor.pushInputData(inputobject).then(() => { audioDecodeProcessor.pushInputData(inputobject).then(() => {
console.info('case queueInput success'); console.info('case queueInput success');
}); });
} }
} }
}
async function dequeueAllOutputs(queue, savapath, done) { async function dequeueAllOutputs(queue, savapath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -546,11 +553,13 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -546,11 +553,13 @@ describe('AudioDecoderReliabilityPromise', function () {
else{ else{
console.info("not last frame, continue"); console.info("not last frame, continue");
} }
if (!lockFlag) {
audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => { audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success'); console.info('release output success');
}); });
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -885,7 +894,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -885,7 +894,7 @@ describe('AudioDecoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'start_0500.pcm'; let savepath = BASIC_PATH + 'start_0500.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, END);
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -985,7 +994,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -985,7 +994,7 @@ describe('AudioDecoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0400', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0400', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0400.pcm'; let savepath = BASIC_PATH + 'flush_0400.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -1000,7 +1009,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -1000,7 +1009,7 @@ describe('AudioDecoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0500.pcm'; let savepath = BASIC_PATH + 'flush_0500.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
...@@ -1029,7 +1038,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -1029,7 +1038,7 @@ describe('AudioDecoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0700', 0, async function (done) { it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0700', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0700.pcm'; let savepath = BASIC_PATH + 'flush_0700.pcm';
let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, END); let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, START, END);
EOSFrameNum = 2; EOSFrameNum = 2;
createAudioDecoder(savepath, mySteps, done); createAudioDecoder(savepath, mySteps, done);
}) })
......
...@@ -47,6 +47,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -47,6 +47,7 @@ describe('AudioEncoderFuncCallback', function () {
let outputCnt = 0; let outputCnt = 0;
let inputCnt = 0; let inputCnt = 0;
let frameThreshold = 10; let frameThreshold = 10;
let lockFlag = false;
beforeAll(async function() { beforeAll(async function() {
console.info('beforeAll case 1'); console.info('beforeAll case 1');
...@@ -72,6 +73,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -72,6 +73,7 @@ describe('AudioEncoderFuncCallback', function () {
ES_LENGTH = 1500; ES_LENGTH = 1500;
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -105,6 +107,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -105,6 +107,7 @@ describe('AudioEncoderFuncCallback', function () {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
} }
async function getFdRead(readPath, done) { async function getFdRead(readPath, done) {
...@@ -162,6 +165,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -162,6 +165,7 @@ describe('AudioEncoderFuncCallback', function () {
} }
async function flushWork(done) { async function flushWork(done) {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
await getFdRead(readpath, done); await getFdRead(readpath, done);
...@@ -170,6 +174,11 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -170,6 +174,11 @@ describe('AudioEncoderFuncCallback', function () {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
workdoneAtEOS =true; workdoneAtEOS =true;
lockFlag = false;
audioEncodeProcessor.start((err) => {
expect(err).assertUndefined();
console.info("case start after flush success");
})
}) })
} }
...@@ -218,12 +227,14 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -218,12 +227,14 @@ describe('AudioEncoderFuncCallback', function () {
} }
timestamp += 23; timestamp += 23;
frameCnt += 1; frameCnt += 1;
if (!lockFlag) {
audioEncodeProcessor.pushInputData(inputobject, () => { audioEncodeProcessor.pushInputData(inputobject, () => {
console.info('queueInput success'); console.info('queueInput success');
inputCnt += 1; inputCnt += 1;
}) })
} }
} }
}
async function dequeueAllOutputs(queue, savepath, done) { async function dequeueAllOutputs(queue, savepath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -246,11 +257,13 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -246,11 +257,13 @@ describe('AudioEncoderFuncCallback', function () {
else{ else{
console.info("write to file success"); console.info("write to file success");
} }
if (!lockFlag) {
audioEncodeProcessor.freeOutputBuffer(outputobject, () => { audioEncodeProcessor.freeOutputBuffer(outputobject, () => {
console.info('release output success'); console.info('release output success');
}) })
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -481,11 +494,17 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -481,11 +494,17 @@ describe('AudioEncoderFuncCallback', function () {
}) })
}); });
eventEmitter.on('flush', () => { eventEmitter.on('flush', () => {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioEncodeProcessor.flush((err) => { audioEncodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush after 2s success`); console.info(`case flush after 2s success`);
lockFlag = false;
audioEncodeProcessor.start((err) => {
expect(err).assertUndefined();
console.info(`case start after flush success`);
})
}) })
}); });
media.createAudioEncoderByMime('audio/mp4a-latm', (err, processor) => { media.createAudioEncoderByMime('audio/mp4a-latm', (err, processor) => {
......
...@@ -47,6 +47,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -47,6 +47,7 @@ describe('AudioEncoderFuncPromise', function () {
let outputCnt = 0; let outputCnt = 0;
let inputCnt = 0; let inputCnt = 0;
let frameThreshold = 10; let frameThreshold = 10;
let lockFlag = false;
beforeAll(async function() { beforeAll(async function() {
...@@ -73,6 +74,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -73,6 +74,7 @@ describe('AudioEncoderFuncPromise', function () {
ES_LENGTH = 1500; ES_LENGTH = 1500;
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -116,6 +118,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -116,6 +118,7 @@ describe('AudioEncoderFuncPromise', function () {
outputQueue = []; outputQueue = [];
outputCnt = 0; outputCnt = 0;
inputCnt = 0; inputCnt = 0;
lockFlag = false;
} }
async function getFdRead(readPath, done) { async function getFdRead(readPath, done) {
...@@ -160,6 +163,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -160,6 +163,7 @@ describe('AudioEncoderFuncPromise', function () {
} }
async function flushWork(done) { async function flushWork(done) {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
await getFdRead(readpath, done); await getFdRead(readpath, done);
...@@ -167,6 +171,10 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -167,6 +171,10 @@ describe('AudioEncoderFuncPromise', function () {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
workdoneAtEOS =true; workdoneAtEOS =true;
lockFlag = false;
}, failCallback).catch(failCatch);
await audioEncodeProcessor.start().then(() => {
console.info("case start after flush success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
} }
...@@ -212,12 +220,14 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -212,12 +220,14 @@ describe('AudioEncoderFuncPromise', function () {
} }
timestamp += 23; timestamp += 23;
frameCnt += 1; frameCnt += 1;
audioEncodeProcessor.pushInputData(inputobject).then(() => { if (!lockFlag) {
await audioEncodeProcessor.pushInputData(inputobject).then(() => {
console.info('case queueInput success'); console.info('case queueInput success');
inputCnt += 1; inputCnt += 1;
}); });
} }
} }
}
async function dequeueOutputs(queue, savepath, done) { async function dequeueOutputs(queue, savepath, done) {
while (queue.length > 0 && !sawOutputEOS) { while (queue.length > 0 && !sawOutputEOS) {
...@@ -242,11 +252,13 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -242,11 +252,13 @@ describe('AudioEncoderFuncPromise', function () {
else{ else{
console.info("write to file success"); console.info("write to file success");
} }
audioEncodeProcessor.freeOutputBuffer(outputobject).then(() => { if (!lockFlag) {
await audioEncodeProcessor.freeOutputBuffer(outputobject).then(() => {
console.info('release output success'); console.info('release output success');
}); });
} }
} }
}
function setCallback(savepath, done) { function setCallback(savepath, done) {
console.info('case callback'); console.info('case callback');
...@@ -423,11 +435,16 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -423,11 +435,16 @@ describe('AudioEncoderFuncPromise', function () {
await audioEncodeProcessor.start().then(() => { await audioEncodeProcessor.start().then(() => {
console.info("case start success") console.info("case start success")
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
await sleep(500).then(() => { await sleep(500).then(async() => {
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioEncodeProcessor.flush().then(() => { await audioEncodeProcessor.flush().then(() => {
console.info("case flush after 5s") console.info("case flush after 5s");
lockFlag = false;
}, failCallback).catch(failCatch);
await audioEncodeProcessor.start().then(() => {
console.info("case start after flush success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
}); });
}) })
......
...@@ -59,6 +59,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -59,6 +59,7 @@ describe('AudioEncoderReliabilityCallback', function () {
"audio_sample_format": 1, "audio_sample_format": 1,
}; };
let fdRead; let fdRead;
let lockFlag = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -80,6 +81,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -80,6 +81,7 @@ describe('AudioEncoderReliabilityCallback', function () {
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
ES_LENGTH = 200; ES_LENGTH = 200;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -110,6 +112,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -110,6 +112,7 @@ describe('AudioEncoderReliabilityCallback', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
lockFlag = false;
} }
async function createAudioEncoder(savepath, mySteps, done) { async function createAudioEncoder(savepath, mySteps, done) {
...@@ -220,6 +223,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -220,6 +223,7 @@ describe('AudioEncoderReliabilityCallback', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioEncodeProcessor.flush(async(err) => { audioEncodeProcessor.flush(async(err) => {
...@@ -231,6 +235,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -231,6 +235,7 @@ describe('AudioEncoderReliabilityCallback', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
lockFlag = false;
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, mediaDescription, done);
}); });
break; break;
...@@ -699,7 +704,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -699,7 +704,7 @@ describe('AudioEncoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_START_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_START_CALLBACK_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'start_0500.es'; let savepath = BASIC_PATH + 'start_0500.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, END);
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
...@@ -799,7 +804,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -799,7 +804,7 @@ describe('AudioEncoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_CALLBACK_0400', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0400.es'; let savepath = BASIC_PATH + 'flush_0400.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
...@@ -814,7 +819,7 @@ describe('AudioEncoderReliabilityCallback', function () { ...@@ -814,7 +819,7 @@ describe('AudioEncoderReliabilityCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0500.es'; let savepath = BASIC_PATH + 'flush_0500.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
......
...@@ -60,6 +60,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -60,6 +60,7 @@ describe('AudioEncoderReliabilityPromise', function () {
}; };
let expectError = false; let expectError = false;
let fdRead; let fdRead;
let lockFlag = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -82,6 +83,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -82,6 +83,7 @@ describe('AudioEncoderReliabilityPromise', function () {
outputQueue = []; outputQueue = [];
ES_LENGTH = 200; ES_LENGTH = 200;
expectError = false; expectError = false;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -128,6 +130,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -128,6 +130,7 @@ describe('AudioEncoderReliabilityPromise', function () {
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
lockFlag = false;
} }
async function createAudioEncoder(savepath, mySteps, done) { async function createAudioEncoder(savepath, mySteps, done) {
...@@ -189,7 +192,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -189,7 +192,7 @@ describe('AudioEncoderReliabilityPromise', function () {
async function nextStep(mySteps, done) { async function nextStep(mySteps, done) {
console.info("case myStep[0]: " + mySteps[0]); console.info("case myStep[0]: " + mySteps[0]);
if (mySteps[0] == END) { if (mySteps[0] == END) {
audioEncodeProcessor.release().then(() => { await audioEncodeProcessor.release().then(() => {
console.info("case release success"); console.info("case release success");
audioEncodeProcessor = null; audioEncodeProcessor = null;
done(); done();
...@@ -199,7 +202,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -199,7 +202,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case CONFIGURE: case CONFIGURE:
mySteps.shift(); mySteps.shift();
console.info(`case to configure`); console.info(`case to configure`);
audioEncodeProcessor.configure(mediaDescription).then(() => { await audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure 1`); console.info(`case configure 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -207,7 +210,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -207,7 +210,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case PREPARE: case PREPARE:
mySteps.shift(); mySteps.shift();
console.info(`case to prepare`); console.info(`case to prepare`);
audioEncodeProcessor.prepare().then(() => { await audioEncodeProcessor.prepare().then(() => {
console.info(`case prepare 1`); console.info(`case prepare 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -221,7 +224,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -221,7 +224,7 @@ describe('AudioEncoderReliabilityPromise', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
enqueueInputs(inputQueue); enqueueInputs(inputQueue);
} }
audioEncodeProcessor.start().then(() => { await audioEncodeProcessor.start().then(() => {
console.info(`case start 1`); console.info(`case start 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -229,9 +232,10 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -229,9 +232,10 @@ describe('AudioEncoderReliabilityPromise', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
lockFlag = true;
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
audioEncodeProcessor.flush().then(async() => { await audioEncodeProcessor.flush().then(async() => {
console.info(`case flush 1`); console.info(`case flush 1`);
if (flushAtEOS) { if (flushAtEOS) {
await getFdRead(AUDIOPATH, done); await getFdRead(AUDIOPATH, done);
...@@ -239,13 +243,14 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -239,13 +243,14 @@ describe('AudioEncoderReliabilityPromise', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
lockFlag = false;
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case STOP: case STOP:
mySteps.shift(); mySteps.shift();
console.info(`case to stop`); console.info(`case to stop`);
audioEncodeProcessor.stop().then(() => { await audioEncodeProcessor.stop().then(() => {
console.info(`case stop 1`); console.info(`case stop 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -254,7 +259,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -254,7 +259,7 @@ describe('AudioEncoderReliabilityPromise', function () {
mySteps.shift(); mySteps.shift();
console.info(`case to reset`); console.info(`case to reset`);
resetParam(); resetParam();
audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info(`case reset 1`); console.info(`case reset 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -272,7 +277,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -272,7 +277,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case CONFIGURE_ERROR: case CONFIGURE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to configure 2`); console.info(`case to configure 2`);
audioEncodeProcessor.configure(mediaDescription).then(() => { await audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure error 1`); console.info(`case configure error 1`);
expect(expectError).assertTrue(); expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
...@@ -280,7 +285,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -280,7 +285,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case PREPARE_ERROR: case PREPARE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to prepare 2`); console.info(`case to prepare 2`);
audioEncodeProcessor.prepare().then(() => { await audioEncodeProcessor.prepare().then(() => {
console.info(`case prepare error 1`); console.info(`case prepare error 1`);
expect(expectError).assertTrue(); expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
...@@ -288,7 +293,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -288,7 +293,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case START_ERROR: case START_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to start 2`); console.info(`case to start 2`);
audioEncodeProcessor.start().then(() => { await audioEncodeProcessor.start().then(() => {
console.info(`case start error 1`); console.info(`case start error 1`);
expect(expectError).assertTrue(); expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
...@@ -296,7 +301,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -296,7 +301,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case FLUSH_ERROR: case FLUSH_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to flush 2`); console.info(`case to flush 2`);
audioEncodeProcessor.flush().then(() => { await audioEncodeProcessor.flush().then(() => {
console.info(`case flush error 1`); console.info(`case flush error 1`);
expect(expectError).assertTrue(); expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
...@@ -304,7 +309,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -304,7 +309,7 @@ describe('AudioEncoderReliabilityPromise', function () {
case STOP_ERROR: case STOP_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to stop 2`); console.info(`case to stop 2`);
audioEncodeProcessor.stop().then(() => { await audioEncodeProcessor.stop().then(() => {
console.info(`case stop error 1`); console.info(`case stop error 1`);
expect(expectError).assertTrue(); expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
...@@ -701,7 +706,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -701,7 +706,7 @@ describe('AudioEncoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_START_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_START_PROMISE_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'start_0500.es'; let savepath = BASIC_PATH + 'start_0500.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, END);
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
...@@ -801,7 +806,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -801,7 +806,7 @@ describe('AudioEncoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0400', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0400', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0400.es'; let savepath = BASIC_PATH + 'flush_0400.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
...@@ -816,7 +821,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -816,7 +821,7 @@ describe('AudioEncoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0500', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0500.es'; let savepath = BASIC_PATH + 'flush_0500.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS); let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START, FLUSH, START, WAITFORALLOUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
...@@ -845,7 +850,7 @@ describe('AudioEncoderReliabilityPromise', function () { ...@@ -845,7 +850,7 @@ describe('AudioEncoderReliabilityPromise', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0700', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_API_FLUSH_PROMISE_0700', 0, async function (done) {
let savepath = BASIC_PATH + 'flush_0700.es'; let savepath = BASIC_PATH + 'flush_0700.es';
let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, END); let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, START, END);
EOSFrameNum = 2; EOSFrameNum = 2;
createAudioEncoder(savepath, mySteps, done); createAudioEncoder(savepath, mySteps, done);
}) })
......
...@@ -19,6 +19,4 @@ require('./VideoDecoderReliCallbackTest.test.js') ...@@ -19,6 +19,4 @@ require('./VideoDecoderReliCallbackTest.test.js')
require('./VideoDecoderReliPromiseTest.test.js') require('./VideoDecoderReliPromiseTest.test.js')
require('./VideoDecoderSoftwareFuncCallbackTest.test.js') require('./VideoDecoderSoftwareFuncCallbackTest.test.js')
require('./VideoDecoderSoftwareFuncPromiseTest.test.js') require('./VideoDecoderSoftwareFuncPromiseTest.test.js')
require('./VideoDecoderSoftwareReliCallbackTest.test.js')
require('./VideoDecoderSoftwareReliPromiseTest.test.js')
require('./VideoDecoderEnumTest.test.js') require('./VideoDecoderEnumTest.test.js')
\ No newline at end of file
...@@ -75,6 +75,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -75,6 +75,7 @@ describe('VideoDecoderReliCallbackTest', function () {
1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124];
let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320;
let fdRead; let fdRead;
let lockFlag = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -97,6 +98,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -97,6 +98,7 @@ describe('VideoDecoderReliCallbackTest', function () {
inputEosFlag = false; inputEosFlag = false;
position = 0; position = 0;
surfaceID = globalThis.value; surfaceID = globalThis.value;
lockFlag = false;
}) })
afterEach(async function() { afterEach(async function() {
...@@ -245,6 +247,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -245,6 +247,7 @@ describe('VideoDecoderReliCallbackTest', function () {
}); });
} }
function toFlush(mySteps, done, expectFail) { function toFlush(mySteps, done, expectFail) {
lockFlag = true;
videoDecodeProcessor.flush((err) => { videoDecodeProcessor.flush((err) => {
console.info(`case flush callback`); console.info(`case flush callback`);
printError(err, expectFail); printError(err, expectFail);
...@@ -255,6 +258,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -255,6 +258,7 @@ describe('VideoDecoderReliCallbackTest', function () {
timestamp = 0; timestamp = 0;
frameCountIn = 1; frameCountIn = 1;
} }
lockFlag = false;
toNextStep(mySteps, done); toNextStep(mySteps, done);
}); });
} }
...@@ -474,7 +478,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -474,7 +478,7 @@ describe('VideoDecoderReliCallbackTest', function () {
*/ */
it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0200', 0, async function (done) { it('SUB_MEDIA_VIDEO_DECODER_FUNCTION_CALLBACK_01_0200', 0, async function (done) {
let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START, let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
DECODE_STEP.FLUSH, DECODE_STEP.WAIT_FOR_ALL_OUTS); DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.WAIT_FOR_ALL_OUTS);
workdoneAtEOS = true; workdoneAtEOS = true;
toCreateVideoDecoderByMime('video/avc', mySteps, done); toCreateVideoDecoderByMime('video/avc', mySteps, done);
}) })
...@@ -825,7 +829,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -825,7 +829,7 @@ describe('VideoDecoderReliCallbackTest', function () {
*/ */
it('SUB_MEDIA_VIDEO_DECODER_API_START_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_DECODER_API_START_CALLBACK_0500', 0, async function (done) {
let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START, let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.ERROR, DECODE_STEP.RELEASE); DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.RELEASE);
toCreateVideoDecoderByMime('video/avc', mySteps, done); toCreateVideoDecoderByMime('video/avc', mySteps, done);
}) })
...@@ -937,7 +941,7 @@ describe('VideoDecoderReliCallbackTest', function () { ...@@ -937,7 +941,7 @@ describe('VideoDecoderReliCallbackTest', function () {
*/ */
it('SUB_MEDIA_VIDEO_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {
let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START, let mySteps = new Array(DECODE_STEP.CONFIGURE, DECODE_STEP.SETSURFACE, DECODE_STEP.PREPARE, DECODE_STEP.START,
DECODE_STEP.FLUSH, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE); DECODE_STEP.FLUSH, DECODE_STEP.START, DECODE_STEP.FLUSH, DECODE_STEP.RELEASE);
toCreateVideoDecoderByMime('video/avc', mySteps, done); toCreateVideoDecoderByMime('video/avc', mySteps, done);
}) })
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"setenforce 0",
"rm -rf /storage/media/100/local/files/*", "rm -rf /storage/media/100/local/files/*",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/", "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/" "chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/"
...@@ -41,7 +40,6 @@ ...@@ -41,7 +40,6 @@
"chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/*" "chmod 777 /data/app/el2/100/base/ohos.acts.multimedia.video.videoencoder/haps/entry/files/*"
], ],
"teardown-command":[ "teardown-command":[
"setenforce 1"
] ]
} }
] ]
......
...@@ -681,6 +681,7 @@ describe('videoHardwareEncoderFuncPromise', function () { ...@@ -681,6 +681,7 @@ describe('videoHardwareEncoderFuncPromise', function () {
needRelease = true; needRelease = true;
await toStartEnc(); await toStartEnc();
await toFlushDec(); await toFlushDec();
await toStartDec();
}); });
}) })
...@@ -705,10 +706,12 @@ describe('videoHardwareEncoderFuncPromise', function () { ...@@ -705,10 +706,12 @@ describe('videoHardwareEncoderFuncPromise', function () {
await sleep(5000); await sleep(5000);
expect(outputEncEos).assertFalse(); expect(outputEncEos).assertFalse();
await toFlushEnc(); await toFlushEnc();
await toStartEnc();
resetReadParam(); resetReadParam();
resetStateParam(); resetStateParam();
needRelease = true; needRelease = true;
await toFlushDec(); await toFlushDec();
await toStartDec();
}) })
/* * /* *
...@@ -731,10 +734,12 @@ describe('videoHardwareEncoderFuncPromise', function () { ...@@ -731,10 +734,12 @@ describe('videoHardwareEncoderFuncPromise', function () {
await startDecProcess(mime, srcPath, mediaDescription2, done); await startDecProcess(mime, srcPath, mediaDescription2, done);
eventEmitter.on('flushAtEos', async() => { eventEmitter.on('flushAtEos', async() => {
await toFlushEnc(); await toFlushEnc();
await toStartEnc();
resetReadParam(); resetReadParam();
resetStateParam(); resetStateParam();
needRelease = true; needRelease = true;
await toFlushDec(); await toFlushDec();
await toStartDec();
}); });
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册