提交 f8482be7 编写于 作者: L ling990

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

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