提交 0795dc4a 编写于 作者: L ling990

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

Signed-off-by: Nling990 <liling96@huawei.com>
上级 b9f292d2
...@@ -18,7 +18,7 @@ import mediademo from '@ohos.multimedia.mediademo' ...@@ -18,7 +18,7 @@ import mediademo from '@ohos.multimedia.mediademo'
import Fileio from '@ohos.fileio' import Fileio from '@ohos.fileio'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('videoEncoderSoftwareFuncPromise', function () { describe('videoSoftwareEncoderFuncPromise', function () {
const BASIC_PATH = '/data/media/results/videoencode_func_promise_'; const BASIC_PATH = '/data/media/results/videoencode_func_promise_';
let videoEncodeProcessor; let videoEncodeProcessor;
let mediaTest; let mediaTest;
...@@ -192,7 +192,7 @@ describe('videoEncoderSoftwareFuncPromise', function () { ...@@ -192,7 +192,7 @@ describe('videoEncoderSoftwareFuncPromise', function () {
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
} }
function printVideoCaps(videoCaps, width, height) { async function printVideoCaps(videoCaps, width, height) {
console.info(`print videoCaps: console.info(`print videoCaps:
codecInfo.name ${videoCaps.codecInfo.name} codecInfo.name ${videoCaps.codecInfo.name}
codecInfo.type ${videoCaps.codecInfo.type} codecInfo.type ${videoCaps.codecInfo.type}
...@@ -212,11 +212,35 @@ describe('videoEncoderSoftwareFuncPromise', function () { ...@@ -212,11 +212,35 @@ describe('videoEncoderSoftwareFuncPromise', function () {
supportedQuality [${videoCaps.supportedQuality.min}, ${videoCaps.supportedQuality.max}] supportedQuality [${videoCaps.supportedQuality.min}, ${videoCaps.supportedQuality.max}]
supportedComplexity [${videoCaps.supportedComplexity.min}, ${videoCaps.supportedComplexity.max}] supportedComplexity [${videoCaps.supportedComplexity.min}, ${videoCaps.supportedComplexity.max}]
`); `);
console.info("videoCaps.getPreferredFrameRate.min: " + videoCaps.getPreferredFrameRate(width, height).min); await videoCaps.getPreferredFrameRate(width, height).then((valueRange) => {
console.info("videoCaps.getPreferredFrameRate.max: " + videoCaps.getPreferredFrameRate(width, height).max); console.info("case getPreferredFrameRate valueRange success");
console.info("videoCaps.getSupportedFrameRate.min: " + videoCaps.getSupportedFrameRate(width, height).min); if (typeof (valueRange) != 'undefined') {
console.info("videoCaps.getSupportedFrameRate.max: " + videoCaps.getSupportedFrameRate(width, height).max); console.info('getPreferredFrameRate.min' + valueRange.min);
console.info("videoCaps.isSizeSupported: " + videoCaps.isSizeSupported(width, height)); console.info('getPreferredFrameRate.max' + valueRange.max);
} else {
console.info('case getPreferredFrameRate valueRange is not defined');
expect().assertFail();
}
}, failCallback).catch(failCatch);
await videoCaps.getSupportedFrameRate(width, height).then((valueRange) => {
console.info("case getSupportedFrameRate valueRange success");
if (typeof (valueRange) != 'undefined') {
console.info('getSupportedFrameRate.min' + valueRange.min);
console.info('getSupportedFrameRate.max' + valueRange.max);
} else {
console.info('case getSupportedFrameRate valueRange is not defined');
expect().assertFail();
}
}, failCallback).catch(failCatch);
await videoCaps.isSizeSupported(width, height).then((trueORfalse) => {
console.info("case isSizeSupported valueRange for width:" + width + ", height: " + height);
if (typeof (trueORfalse) != 'undefined') {
console.info('videoCaps.isSizeSupported: ' + trueORfalse);
} else {
console.info('case isSizeSupported is not defined');
expect().assertFail();
}
}, failCallback).catch(failCatch);
} }
function toCreateStream() { function toCreateStream() {
......
...@@ -1432,7 +1432,8 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -1432,7 +1432,8 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
} }
}) })
}) })
/* *
/* *
* @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100 * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100
* @tc.name : 001. create -> release for 50 times * @tc.name : 001. create -> release for 50 times
* @tc.desc : Reliability Test * @tc.desc : Reliability Test
...@@ -1440,7 +1441,7 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -1440,7 +1441,7 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
* @tc.type : Reliability * @tc.type : Reliability
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100', 0, async function (done) { it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOOPLOOP_CALLBACK_0100', 0, async function (done) {
let name = 'avenc_mpeg4'; let name = 'avenc_mpeg4';
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
...@@ -1474,5 +1475,99 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { ...@@ -1474,5 +1475,99 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () {
}) })
eventEmitter.emit('create', name); eventEmitter.emit('create', name);
}) })
/* *
* @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOOPLOOP_CALLBACK_0100
* @tc.name : 001. total loop for 50 times
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100', 0, async function (done) {
let name = 'avenc_mpeg4';
let events = require('events');
let eventEmitter = new events.EventEmitter();
let loopCnt = 0;
eventEmitter.on('create', (name) => {
media.createVideoEncoderByName(name, (err, processor) => {
expect(err).assertUndefined();
if (typeof(processor) != 'undefined') {
videoEncodeProcessor = processor;
eventEmitter.emit('configure', mediaDescription);
} else {
console.info('in case : createVideoEncoderByName fail');
expect().assertFail();
done();
}
})
})
eventEmitter.on('configure', (mediaDescription) => {
videoEncodeProcessor.configure(mediaDescription, (err) => {
expect(err).assertUndefined();
console.info(`case configure 1`);
eventEmitter.emit('getInputSurface');
})
});
eventEmitter.on('getInputSurface', () => {
videoEncodeProcessor.getInputSurface((err, inputSurface) => {
expect(err).assertUndefined();
expect(inputSurface != undefined).assertTrue();
surfaceID = inputSurface;
console.info('in case : getInputSurface success, surfaceID ' + surfaceID);
eventEmitter.emit('prepare');
})
});
eventEmitter.on('prepare', () => {
videoEncodeProcessor.prepare((err) => {
expect(err).assertUndefined();
console.info('in case : prepare success');
eventEmitter.emit('start');
});
});
eventEmitter.on('start', () => {
videoEncodeProcessor.start((err) => {
expect(err).assertUndefined();
console.info('in case : start success');
eventEmitter.emit('flush');
});
});
eventEmitter.on('flush', () => {
videoEncodeProcessor.flush((err) => {
expect(err).assertUndefined();
console.info('in case : flush success');
eventEmitter.emit('stop');
});
});
eventEmitter.on('stop', () => {
videoEncodeProcessor.stop((err) => {
expect(err).assertUndefined();
console.info('in case : stop success');
eventEmitter.emit('reset');
});
});
eventEmitter.on('reset', () => {
videoEncodeProcessor.reset((err) => {
expect(err).assertUndefined();
console.info('in case : reset success');
eventEmitter.emit('release');
});
});
eventEmitter.on('release', () => {
videoEncodeProcessor.release((err) => {
expect(err).assertUndefined();
console.info(`case release 1`);
videoEncodeProcessor = null;
loopCnt += 1;
if (loopCnt < 50) {
console.info('case create-release current loop: ' + loopCnt);
eventEmitter.emit('create', name);
} else {
done();
}
})
})
eventEmitter.emit('create', name);
})
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册