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

!1892 modify flush

Merge pull request !1892 from ling990/ling990
...@@ -60,14 +60,13 @@ describe('AudioDecoderFormatCallback', function () { ...@@ -60,14 +60,13 @@ describe('AudioDecoderFormatCallback', function () {
isVorbis = false; isVorbis = false;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null) { if (audioDecodeProcessor != null) {
audioDecodeProcessor.release((err) => { await audioDecodeProcessor.release().then(() => {
expect(err).assertUndefined(); console.info('audioDecodeProcessor release success');
console.log("case release success");
audioDecodeProcessor = null; audioDecodeProcessor = null;
}) }, failCallback).catch(failCatch);
} }
}) })
...@@ -148,6 +147,8 @@ describe('AudioDecoderFormatCallback', function () { ...@@ -148,6 +147,8 @@ describe('AudioDecoderFormatCallback', function () {
audioDecodeProcessor.stop((err) => { audioDecodeProcessor.stop((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.log("stop success"); console.log("stop success");
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.log("reset success"); console.log("reset success");
......
...@@ -60,10 +60,10 @@ describe('AudioDecoderFormatPromise', function () { ...@@ -60,10 +60,10 @@ describe('AudioDecoderFormatPromise', function () {
isVorbis = false; isVorbis = false;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null){ if (audioDecodeProcessor != null) {
audioDecodeProcessor.release().then(() => { await audioDecodeProcessor.release().then(() => {
console.info('audioDecodeProcessor release success'); console.info('audioDecodeProcessor release success');
audioDecodeProcessor = null; audioDecodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -157,6 +157,8 @@ describe('AudioDecoderFormatPromise', function () { ...@@ -157,6 +157,8 @@ describe('AudioDecoderFormatPromise', function () {
await audioDecodeProcessor.stop().then(() => { await audioDecodeProcessor.stop().then(() => {
console.log("stop success"); console.log("stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
inputQueue = [];
outputQueue = [];
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.log("reset success"); console.log("reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
......
...@@ -246,11 +246,10 @@ describe('AudioDecoderFunc', function () { ...@@ -246,11 +246,10 @@ describe('AudioDecoderFunc', function () {
afterEach(async function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null) { if (audioDecodeProcessor != null) {
audioDecodeProcessor.release((err) => { await audioDecodeProcessor.release().then(() => {
expect(err).assertUndefined(); console.info('audioDecodeProcessor release success');
console.log("case release success");
audioDecodeProcessor = null; audioDecodeProcessor = null;
}) }, failCallback).catch(failCatch);
} }
}) })
...@@ -272,6 +271,8 @@ describe('AudioDecoderFunc', function () { ...@@ -272,6 +271,8 @@ describe('AudioDecoderFunc', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeFile(path, buf, len){ function writeFile(path, buf, len){
...@@ -310,6 +311,7 @@ describe('AudioDecoderFunc', function () { ...@@ -310,6 +311,7 @@ describe('AudioDecoderFunc', function () {
} }
async function resetWork() { async function resetWork() {
resetParam();
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case reset success"); console.info("case reset success");
...@@ -324,6 +326,8 @@ describe('AudioDecoderFunc', function () { ...@@ -324,6 +326,8 @@ describe('AudioDecoderFunc', function () {
} }
async function flushWork() { async function flushWork() {
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.flush((err) => { audioDecodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
...@@ -337,6 +341,7 @@ describe('AudioDecoderFunc', function () { ...@@ -337,6 +341,7 @@ describe('AudioDecoderFunc', function () {
audioDecodeProcessor.stop((err) => { audioDecodeProcessor.stop((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case stop success"); console.info("case stop success");
resetParam();
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.log("case reset success"); console.log("case reset success");
...@@ -397,7 +402,9 @@ describe('AudioDecoderFunc', function () { ...@@ -397,7 +402,9 @@ describe('AudioDecoderFunc', function () {
await flushWork(); await flushWork();
} else if (workdoneAtEOS) { } else if (workdoneAtEOS) {
await doneWork(done); await doneWork(done);
} else {} } else {
console.info("saw output EOS");
}
} }
else{ else{
writeFile(savepath, outputobject.data, outputobject.length); writeFile(savepath, outputobject.data, outputobject.length);
...@@ -640,6 +647,8 @@ describe('AudioDecoderFunc', function () { ...@@ -640,6 +647,8 @@ describe('AudioDecoderFunc', function () {
}) })
}); });
eventEmitter.on('flush', () => { eventEmitter.on('flush', () => {
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.flush((err) => { audioDecodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush after 2s`); console.info(`case flush after 2s`);
...@@ -771,6 +780,7 @@ describe('AudioDecoderFunc', function () { ...@@ -771,6 +780,7 @@ describe('AudioDecoderFunc', function () {
}) })
}); });
eventEmitter.on('reset', () => { eventEmitter.on('reset', () => {
resetParam();
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case reset 1`); console.info(`case reset 1`);
......
...@@ -243,10 +243,10 @@ describe('AudioDecoderFunc', function () { ...@@ -243,10 +243,10 @@ describe('AudioDecoderFunc', function () {
ES_LENGTH = 1500; ES_LENGTH = 1500;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null) { if (audioDecodeProcessor != null) {
audioDecodeProcessor.release().then(() => { await audioDecodeProcessor.release().then(() => {
console.info('audioDecodeProcessor release success'); console.info('audioDecodeProcessor release success');
audioDecodeProcessor = null; audioDecodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -281,6 +281,8 @@ describe('AudioDecoderFunc', function () { ...@@ -281,6 +281,8 @@ describe('AudioDecoderFunc', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeFile(path, buf, len) { function writeFile(path, buf, len) {
...@@ -317,6 +319,7 @@ describe('AudioDecoderFunc', function () { ...@@ -317,6 +319,7 @@ describe('AudioDecoderFunc', function () {
} }
async function resetWork() { async function resetWork() {
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
...@@ -326,6 +329,8 @@ describe('AudioDecoderFunc', function () { ...@@ -326,6 +329,8 @@ describe('AudioDecoderFunc', function () {
} }
async function flushWork() { async function flushWork() {
inputQueue = [];
outputQueue = [];
await audioDecodeProcessor.flush().then(() => { await audioDecodeProcessor.flush().then(() => {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
...@@ -338,6 +343,7 @@ describe('AudioDecoderFunc', function () { ...@@ -338,6 +343,7 @@ describe('AudioDecoderFunc', function () {
await audioDecodeProcessor.stop().then(() => { await audioDecodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -394,7 +400,9 @@ describe('AudioDecoderFunc', function () { ...@@ -394,7 +400,9 @@ describe('AudioDecoderFunc', function () {
} else if (workdoneAtEOS) { } else if (workdoneAtEOS) {
await doneWork(); await doneWork();
done(); done();
} else {} } else {
console.info("saw output EOS");
}
} }
else{ else{
writeFile(savapath, outputobject.data, outputobject.length); writeFile(savapath, outputobject.data, outputobject.length);
...@@ -568,6 +576,8 @@ describe('AudioDecoderFunc', function () { ...@@ -568,6 +576,8 @@ describe('AudioDecoderFunc', function () {
console.info("case start success"); console.info("case start success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
await sleep(3000).then(() => { await sleep(3000).then(() => {
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.flush().then(() => { audioDecodeProcessor.flush().then(() => {
console.info("case flush after 5s"); console.info("case flush after 5s");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -652,6 +662,7 @@ describe('AudioDecoderFunc', function () { ...@@ -652,6 +662,7 @@ describe('AudioDecoderFunc', function () {
audioDecodeProcessor.stop().then(() => { audioDecodeProcessor.stop().then(() => {
console.info("case stop after 5s success"); console.info("case stop after 5s success");
}, failCallback).catch(failCatch);}); }, failCallback).catch(failCatch);});
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
......
...@@ -78,6 +78,8 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -78,6 +78,8 @@ describe('AudioDecoderMultiInstances', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeFile(path, buf, len) { function writeFile(path, buf, len) {
...@@ -114,6 +116,7 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -114,6 +116,7 @@ describe('AudioDecoderMultiInstances', function () {
} }
async function resetWork(audioDecodeProcessor) { async function resetWork(audioDecodeProcessor) {
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
...@@ -123,6 +126,8 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -123,6 +126,8 @@ describe('AudioDecoderMultiInstances', function () {
} }
async function flushWork(audioDecodeProcessor) { async function flushWork(audioDecodeProcessor) {
inputQueue = [];
outputQueue = [];
await audioDecodeProcessor.flush().then(() => { await audioDecodeProcessor.flush().then(() => {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
...@@ -135,6 +140,7 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -135,6 +140,7 @@ describe('AudioDecoderMultiInstances', function () {
await audioDecodeProcessor.stop().then(() => { await audioDecodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -188,7 +194,9 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -188,7 +194,9 @@ describe('AudioDecoderMultiInstances', function () {
} else if (workdoneAtEOS) { } else if (workdoneAtEOS) {
await doneWork(audioDecodeProcessor); await doneWork(audioDecodeProcessor);
done(); done();
} else {} } else {
console.info("saw output EOS");
}
} }
else{ else{
writeFile(savapath, outputobject.data, outputobject.length); writeFile(savapath, outputobject.data, outputobject.length);
...@@ -251,6 +259,7 @@ describe('AudioDecoderMultiInstances', function () { ...@@ -251,6 +259,7 @@ describe('AudioDecoderMultiInstances', function () {
console.info('case has created 16 decoders'); console.info('case has created 16 decoders');
console.info('case array: ' + array); console.info('case array: ' + array);
for (let j = 0; j < 16; j++) { for (let j = 0; j < 16; j++) {
resetParam();
await array[j].reset().then(() => { await array[j].reset().then(() => {
console.info("reset decoder " + j); console.info("reset decoder " + j);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
......
...@@ -257,14 +257,13 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -257,14 +257,13 @@ describe('AudioDecoderReliabilityCallback', function () {
ES_LENGTH = 500; ES_LENGTH = 500;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null) { if (audioDecodeProcessor != null) {
audioDecodeProcessor.release((err) => { await audioDecodeProcessor.release().then(() => {
expect(err).assertUndefined(); console.info('audioDecodeProcessor release success');
console.log("case release success");
audioDecodeProcessor = null; audioDecodeProcessor = null;
}) }, failCallback).catch(failCatch);
} }
}) })
...@@ -283,6 +282,8 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -283,6 +282,8 @@ describe('AudioDecoderReliabilityCallback', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function createAudioDecoder(savepath, mySteps, done) { function createAudioDecoder(savepath, mySteps, done) {
...@@ -328,6 +329,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -328,6 +329,7 @@ describe('AudioDecoderReliabilityCallback', function () {
audioDecodeProcessor.stop((err) => { audioDecodeProcessor.stop((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case stop success"); console.info("case stop success");
resetParam();
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.log("case reset success"); console.log("case reset success");
...@@ -398,6 +400,8 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -398,6 +400,8 @@ describe('AudioDecoderReliabilityCallback', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.flush((err) => { audioDecodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush 1`); console.info(`case flush 1`);
...@@ -422,6 +426,7 @@ describe('AudioDecoderReliabilityCallback', function () { ...@@ -422,6 +426,7 @@ describe('AudioDecoderReliabilityCallback', function () {
case RESET: case RESET:
mySteps.shift(); mySteps.shift();
console.info(`case to reset`); console.info(`case to reset`);
resetParam();
audioDecodeProcessor.reset((err) => { audioDecodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case reset 1`); console.info(`case reset 1`);
......
...@@ -261,10 +261,10 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -261,10 +261,10 @@ describe('AudioDecoderReliabilityPromise', function () {
expectError = false; expectError = false;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioDecodeProcessor != null) { if (audioDecodeProcessor != null) {
audioDecodeProcessor.release().then(() => { await audioDecodeProcessor.release().then(() => {
console.info('audioDecodeProcessor release success'); console.info('audioDecodeProcessor release success');
audioDecodeProcessor = null; audioDecodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -303,6 +303,8 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -303,6 +303,8 @@ describe('AudioDecoderReliabilityPromise', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function createAudioDecoder(savepath, mySteps, done) { function createAudioDecoder(savepath, mySteps, done) {
...@@ -348,6 +350,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -348,6 +350,7 @@ describe('AudioDecoderReliabilityPromise', function () {
await audioDecodeProcessor.stop().then(() => { await audioDecodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioDecodeProcessor.reset().then(() => { await audioDecodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -409,6 +412,8 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -409,6 +412,8 @@ describe('AudioDecoderReliabilityPromise', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
inputQueue = [];
outputQueue = [];
audioDecodeProcessor.flush().then(() => { audioDecodeProcessor.flush().then(() => {
console.info(`case flush 1`); console.info(`case flush 1`);
if (flushAtEOS) { if (flushAtEOS) {
...@@ -431,6 +436,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -431,6 +436,7 @@ describe('AudioDecoderReliabilityPromise', function () {
case RESET: case RESET:
mySteps.shift(); mySteps.shift();
console.info(`case to reset`); console.info(`case to reset`);
resetParam();
audioDecodeProcessor.reset().then(() => { audioDecodeProcessor.reset().then(() => {
console.info(`case reset 1`); console.info(`case reset 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
......
...@@ -63,14 +63,13 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -63,14 +63,13 @@ describe('AudioEncoderFuncCallback', function () {
ES_LENGTH = 2000; ES_LENGTH = 2000;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
audioEncodeProcessor.release((err) => { await audioEncodeProcessor.release().then(() => {
expect(err).assertUndefined(); console.info('audioEncodeProcessor release success');
console.log("case release success");
audioEncodeProcessor = null; audioEncodeProcessor = null;
}) }, failCallback).catch(failCatch);
} }
}) })
...@@ -91,6 +90,8 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -91,6 +90,8 @@ describe('AudioEncoderFuncCallback', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeHead(path, len) { function writeHead(path, len) {
...@@ -156,6 +157,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -156,6 +157,7 @@ describe('AudioEncoderFuncCallback', function () {
} }
async function resetWork() { async function resetWork() {
resetParam();
audioEncodeProcessor.reset((err) => { audioEncodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case reset success"); console.info("case reset success");
...@@ -166,6 +168,8 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -166,6 +168,8 @@ describe('AudioEncoderFuncCallback', function () {
} }
async function flushWork() { async function flushWork() {
inputQueue = [];
outputQueue = [];
audioEncodeProcessor.flush((err) => { audioEncodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
...@@ -179,6 +183,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -179,6 +183,7 @@ describe('AudioEncoderFuncCallback', function () {
audioEncodeProcessor.stop((err) => { audioEncodeProcessor.stop((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case stop success"); console.info("case stop success");
resetParam();
audioEncodeProcessor.reset((err) => { audioEncodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
audioEncodeProcessor.release((err) => { audioEncodeProcessor.release((err) => {
...@@ -290,7 +295,6 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -290,7 +295,6 @@ describe('AudioEncoderFuncCallback', function () {
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_CALLBACK_00_0100', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_FUNCTION_CALLBACK_00_0100', 0, async function (done) {
console.info("test set EOS after last frame and reset"); console.info("test set EOS after last frame and reset");
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
let mediaDescription = { let mediaDescription = {
...@@ -356,7 +360,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -356,7 +360,7 @@ describe('AudioEncoderFuncCallback', function () {
} }
}) })
}) })
media.createAudioEncoderByName('avdec_aac', (err, processor) => { media.createAudioEncoderByName('avenc_aac', (err, processor) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case createAudioEncoder by mime 1`); console.info(`case createAudioEncoder by mime 1`);
audioEncodeProcessor = processor; audioEncodeProcessor = processor;
...@@ -473,6 +477,8 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -473,6 +477,8 @@ describe('AudioEncoderFuncCallback', function () {
}) })
}); });
eventEmitter.on('flush', () => { eventEmitter.on('flush', () => {
inputQueue = [];
outputQueue = [];
audioEncodeProcessor.flush((err) => { audioEncodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush after 5s`); console.info(`case flush after 5s`);
...@@ -603,6 +609,7 @@ describe('AudioEncoderFuncCallback', function () { ...@@ -603,6 +609,7 @@ describe('AudioEncoderFuncCallback', function () {
}) })
}); });
eventEmitter.on('reset', () => { eventEmitter.on('reset', () => {
resetParam();
audioEncodeProcessor.reset((err) => { audioEncodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case reset 1`); console.info(`case reset 1`);
......
...@@ -63,10 +63,10 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -63,10 +63,10 @@ describe('AudioEncoderFuncPromise', function () {
ES_LENGTH = 2000; ES_LENGTH = 2000;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
audioEncodeProcessor.release().then(() => { await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success'); console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null; audioEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -100,6 +100,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -100,6 +100,8 @@ describe('AudioEncoderFuncPromise', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeHead(path, len) { function writeHead(path, len) {
...@@ -165,6 +167,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -165,6 +167,7 @@ describe('AudioEncoderFuncPromise', function () {
} }
async function resetWork() { async function resetWork() {
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
...@@ -174,6 +177,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -174,6 +177,8 @@ describe('AudioEncoderFuncPromise', function () {
} }
async function flushWork() { async function flushWork() {
inputQueue = [];
outputQueue = [];
await audioEncodeProcessor.flush().then(() => { await audioEncodeProcessor.flush().then(() => {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
...@@ -186,6 +191,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -186,6 +191,7 @@ describe('AudioEncoderFuncPromise', function () {
await audioEncodeProcessor.stop().then(() => { await audioEncodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -427,6 +433,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -427,6 +433,8 @@ describe('AudioEncoderFuncPromise', function () {
console.info("case start success") console.info("case start success")
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
await sleep(5000).then(() => { await sleep(5000).then(() => {
inputQueue = [];
outputQueue = [];
audioEncodeProcessor.flush().then(() => { audioEncodeProcessor.flush().then(() => {
console.info("case flush after 5s") console.info("case flush after 5s")
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -511,6 +519,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -511,6 +519,7 @@ describe('AudioEncoderFuncPromise', function () {
audioEncodeProcessor.stop().then(() => { audioEncodeProcessor.stop().then(() => {
console.info("stop after 5s success"); console.info("stop after 5s success");
}, failCallback).catch(failCatch);}); }, failCallback).catch(failCatch);});
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("reset success"); console.info("reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -627,7 +636,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -627,7 +636,7 @@ describe('AudioEncoderFuncPromise', function () {
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
let savepath2 = BASIC_PATH + '0601.txt'; let savepath2 = BASIC_PATH + '0601.txt';
workdoneAtEOS = true; workdoneAtEOS = true;
setCallback(audioEncodeProcessor, savepath2, done); setCallback(savepath2, done);
await audioEncodeProcessor.prepare().then(() => { await audioEncodeProcessor.prepare().then(() => {
console.info("prepare2 success"); console.info("prepare2 success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
......
...@@ -92,6 +92,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -92,6 +92,8 @@ describe('AudioEncoderFuncPromise', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function writeHead(path, len) { function writeHead(path, len) {
...@@ -157,6 +159,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -157,6 +159,7 @@ describe('AudioEncoderFuncPromise', function () {
} }
async function resetWork(audioEncodeProcessor) { async function resetWork(audioEncodeProcessor) {
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
if (needrelease) { if (needrelease) {
...@@ -166,6 +169,8 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -166,6 +169,8 @@ describe('AudioEncoderFuncPromise', function () {
} }
async function flushWork(audioEncodeProcessor) { async function flushWork(audioEncodeProcessor) {
inputQueue = [];
outputQueue = [];
await audioEncodeProcessor.flush().then(() => { await audioEncodeProcessor.flush().then(() => {
console.info("case flush at inputeos success"); console.info("case flush at inputeos success");
resetParam(); resetParam();
...@@ -178,6 +183,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -178,6 +183,7 @@ describe('AudioEncoderFuncPromise', function () {
await audioEncodeProcessor.stop().then(() => { await audioEncodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -276,14 +282,14 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -276,14 +282,14 @@ describe('AudioEncoderFuncPromise', function () {
} }
/* * /* *
* @tc.number : SUB_MEDIA_AUDIO_ENCODER_MULTIINSTANCE_PROMISE_0100 * @tc.number : SUB_MEDIA_AUDIO_ENCODER_MULTIINSTANCE_0100
* @tc.name : 001.create 16 encoder * @tc.name : 001.create 16 encoder
* @tc.desc : basic encode function * @tc.desc : basic encode function
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_AUDIO_ENCODER_MULTIINSTANCE_PROMISE_0100', 0, async function (done) { it('SUB_MEDIA_AUDIO_ENCODER_MULTIINSTANCE_0100', 0, async function (done) {
console.info("case test multiple encoder instances"); console.info("case test multiple encoder instances");
let array = new Array(); let array = new Array();
for (let i = 0; i < 16; i += 1) { for (let i = 0; i < 16; i += 1) {
...@@ -299,6 +305,7 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -299,6 +305,7 @@ describe('AudioEncoderFuncPromise', function () {
console.info('case has created 16 encoders'); console.info('case has created 16 encoders');
console.info('case array: ' + array); console.info('case array: ' + array);
for (let j = 0; j < 16; j++) { for (let j = 0; j < 16; j++) {
resetParam();
await array[j].reset().then(() => { await array[j].reset().then(() => {
console.info("reset encoder " + j); console.info("reset encoder " + j);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
......
...@@ -80,14 +80,13 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -80,14 +80,13 @@ describe('AudioEncoderSTTCallback', function () {
ES_LENGTH = 200; ES_LENGTH = 200;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
audioEncodeProcessor.release((err) => { await audioEncodeProcessor.release().then(() => {
expect(err).assertUndefined(); console.info('audioEncodeProcessor release success');
console.log("case release success");
audioEncodeProcessor = null; audioEncodeProcessor = null;
}) }, failCallback).catch(failCatch);
} }
}) })
...@@ -106,6 +105,8 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -106,6 +105,8 @@ describe('AudioEncoderSTTCallback', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function createAudioEncoder(savepath, mySteps, done) { function createAudioEncoder(savepath, mySteps, done) {
...@@ -178,6 +179,7 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -178,6 +179,7 @@ describe('AudioEncoderSTTCallback', function () {
audioEncodeProcessor.stop((err) => { audioEncodeProcessor.stop((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info("case stop success"); console.info("case stop success");
resetParam();
audioEncodeProcessor.reset((err) => { audioEncodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.log("case reset success"); console.log("case reset success");
...@@ -247,6 +249,8 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -247,6 +249,8 @@ describe('AudioEncoderSTTCallback', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
inputQueue = [];
outputQueue = [];
audioEncodeProcessor.flush((err) => { audioEncodeProcessor.flush((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case flush 1`); console.info(`case flush 1`);
...@@ -271,6 +275,7 @@ describe('AudioEncoderSTTCallback', function () { ...@@ -271,6 +275,7 @@ describe('AudioEncoderSTTCallback', function () {
case RESET: case RESET:
mySteps.shift(); mySteps.shift();
console.info(`case to reset`); console.info(`case to reset`);
resetParam();
audioEncodeProcessor.reset((err) => { audioEncodeProcessor.reset((err) => {
expect(err).assertUndefined(); expect(err).assertUndefined();
console.info(`case reset 1`); console.info(`case reset 1`);
......
...@@ -82,10 +82,10 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -82,10 +82,10 @@ describe('AudioEncoderSTTPromise', function () {
expectError = false; expectError = false;
}) })
afterEach(function() { afterEach(async function() {
console.info('afterEach case'); console.info('afterEach case');
if (audioEncodeProcessor != null) { if (audioEncodeProcessor != null) {
audioEncodeProcessor.release().then(() => { await audioEncodeProcessor.release().then(() => {
console.info('audioEncodeProcessor release success'); console.info('audioEncodeProcessor release success');
audioEncodeProcessor = null; audioEncodeProcessor = null;
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -123,6 +123,8 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -123,6 +123,8 @@ describe('AudioEncoderSTTPromise', function () {
timestamp = 0; timestamp = 0;
sawInputEOS = false; sawInputEOS = false;
sawOutputEOS = false; sawOutputEOS = false;
inputQueue = [];
outputQueue = [];
} }
function createAudioEncoder(savepath, mySteps, done) { function createAudioEncoder(savepath, mySteps, done) {
...@@ -195,6 +197,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -195,6 +197,7 @@ describe('AudioEncoderSTTPromise', function () {
await audioEncodeProcessor.stop().then(() => { await audioEncodeProcessor.stop().then(() => {
console.info("case stop success"); console.info("case stop success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
resetParam();
await audioEncodeProcessor.reset().then(() => { await audioEncodeProcessor.reset().then(() => {
console.info("case reset success"); console.info("case reset success");
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
...@@ -257,6 +260,8 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -257,6 +260,8 @@ describe('AudioEncoderSTTPromise', function () {
case FLUSH: case FLUSH:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush`);
inputQueue = [];
outputQueue = [];
audioEncodeProcessor.flush().then(() => { audioEncodeProcessor.flush().then(() => {
console.info(`case flush 1`); console.info(`case flush 1`);
if (flushAtEOS) { if (flushAtEOS) {
...@@ -279,6 +284,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -279,6 +284,7 @@ describe('AudioEncoderSTTPromise', function () {
case RESET: case RESET:
mySteps.shift(); mySteps.shift();
console.info(`case to reset`); console.info(`case to reset`);
resetParam();
audioEncodeProcessor.reset().then(() => { audioEncodeProcessor.reset().then(() => {
console.info(`case reset 1`); console.info(`case reset 1`);
nextStep(mySteps, done); nextStep(mySteps, done);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册