How to use createAudioDecoder method in wpt

Best JavaScript code snippet using wpt

AudioDecoderReliabilityPromiseTest.test.js

Source:AudioDecoderReliabilityPromiseTest.test.js Github

copy

Full Screen

...300 sawOutputEOS = false;301 inputQueue = [];302 outputQueue = [];303 }304 async function createAudioDecoder(savepath, mySteps, done) {305 await getFdRead(AUDIOPATH, done);306 media.createAudioDecoderByMime(mime, (err, processor) => {307 expect(err).assertUndefined();308 console.info(`case createAudioDecoder 1`);309 audioDecodeProcessor = processor;310 setCallback(savepath, done);311 console.info("case start api test");312 nextStep(mySteps, done);313 })314 }315 async function getFdRead(pathName, done) {316 await getFileDescriptor(pathName).then((res) => {317 if (res == undefined) {318 expect().assertFail();319 console.info('case error fileDescriptor undefined, open file fail');320 done();321 } else {322 fdRead = res.fd;323 console.info("case fdRead is: " + fdRead);324 }325 })326 }327 function readFile(path) {328 console.info('case read file start execution');329 try{330 console.info('case filepath: ' + path);331 readStreamSync = fileio.fdopenStreamSync(fdRead, 'rb');332 }catch(e) {333 console.info(e);334 }335 }336 function getContent(buf, len) {337 console.info("case start get content");338 let lengthreal = -1;339 lengthreal = readStreamSync.readSync(buf,{length:len});340 console.info('case lengthreal is :' + lengthreal);341 }342 async function doneWork() {343 await audioDecodeProcessor.stop().then(() => {344 console.info("case stop success");345 }, failCallback).catch(failCatch);346 resetParam();347 await audioDecodeProcessor.reset().then(() => {348 console.info("case reset success");349 }, failCallback).catch(failCatch);350 await audioDecodeProcessor.release().then(() => {351 console.info("case release success");352 }, failCallback).catch(failCatch);353 audioDecodeProcessor = null;354 }355 function sleep(time) {356 return new Promise((resolve) => setTimeout(resolve, time));357 }358 function wait(time) {359 for(let t = Date.now(); Date.now() - t <= time;);360 }361 async function nextStep(mySteps, done) {362 console.info("case myStep[0]: " + mySteps[0]);363 if (mySteps[0] == END) {364 audioDecodeProcessor.release().then(() => {365 console.info("case release success");366 audioDecodeProcessor = null;367 done();368 }, failCallback).catch(failCatch);369 }370 switch (mySteps[0]) {371 case CONFIGURE:372 mySteps.shift();373 console.info(`case to configure`);374 audioDecodeProcessor.configure(mediaDescription).then(() => {375 console.info(`case configure 1`);376 readFile(AUDIOPATH);377 nextStep(mySteps, done);378 }, failCallback).catch(failCatch);379 break;380 case PREPARE:381 mySteps.shift();382 console.info(`case to prepare`);383 audioDecodeProcessor.prepare().then(() => {384 console.info(`case prepare 1`);385 nextStep(mySteps, done);386 }, failCallback).catch(failCatch);387 break;388 case START:389 mySteps.shift();390 console.info(`case to start`);391 if (sawOutputEOS) {392 resetParam();393 await closeFileDescriptor(AUDIOPATH);394 await getFdRead(AUDIOPATH, done);395 readFile(AUDIOPATH);396 workdoneAtEOS = true;397 enqueueAllInputs(inputQueue);398 }399 audioDecodeProcessor.start().then(() => {400 console.info(`case start 1`);401 nextStep(mySteps, done);402 }, failCallback).catch(failCatch);403 break;404 case FLUSH:405 mySteps.shift();406 console.info(`case to flush`);407 inputQueue = [];408 outputQueue = [];409 audioDecodeProcessor.flush().then(async() => {410 console.info(`case flush 1`);411 if (flushAtEOS) {412 await closeFileDescriptor(AUDIOPATH);413 await getFdRead(AUDIOPATH, done);414 resetParam();415 readFile(AUDIOPATH);416 workdoneAtEOS = true;417 flushAtEOS = false;418 }419 nextStep(mySteps, done);420 }, failCallback).catch(failCatch);421 break;422 case STOP:423 mySteps.shift();424 console.info(`case to stop`);425 audioDecodeProcessor.stop().then(() => {426 console.info(`case stop 1`);427 nextStep(mySteps, done);428 }, failCallback).catch(failCatch);429 break;430 case RESET:431 mySteps.shift();432 console.info(`case to reset`);433 resetParam();434 audioDecodeProcessor.reset().then(() => {435 console.info(`case reset 1`);436 nextStep(mySteps, done);437 }, failCallback).catch(failCatch);438 break;439 case HOLDON:440 mySteps.shift();441 setTimeout(() =>{442 nextStep(mySteps, done);443 }, WAITTIME);444 break;445 case WAITFORALLOUTS:446 mySteps.shift();447 console.info(`case wait for all outputs`);448 break;449 case CONFIGURE_ERROR:450 mySteps.shift();451 console.info(`case to configure 2`);452 audioDecodeProcessor.configure(mediaDescription).then(() => {453 console.info(`case configure error 1`);454 expect(expectError).assertTrue();455 }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);456 break;457 case PREPARE_ERROR:458 mySteps.shift();459 console.info(`case to prepare 2`);460 audioDecodeProcessor.prepare().then(() => {461 console.info(`case prepare error 1`);462 expect(expectError).assertTrue();463 }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);464 break;465 case START_ERROR:466 mySteps.shift();467 console.info(`case to start 2`);468 audioDecodeProcessor.start().then(() => {469 console.info(`case start error 1`);470 expect(expectError).assertTrue();471 }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);472 break;473 case FLUSH_ERROR:474 mySteps.shift();475 console.info(`case to flush 2`);476 audioDecodeProcessor.flush().then(() => {477 console.info(`case flush error 1`);478 expect(expectError).assertTrue();479 }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);480 break;481 case STOP_ERROR:482 mySteps.shift();483 console.info(`case to stop 2`);484 audioDecodeProcessor.stop().then(() => {485 console.info(`case stop error 1`);486 expect(expectError).assertTrue();487 }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);488 break;489 case JUDGE_EOS:490 mySteps.shift();491 console.info(`case judge EOS state`);492 expect(sawOutputEOS).assertTrue();493 nextStep(mySteps, done);494 break;495 default:496 break;497 }498 }499 async function enqueueAllInputs(queue) {500 while (queue.length > 0 && !sawInputEOS) {501 let inputobject = queue.shift();502 if (frameCnt == EOSFrameNum || frameCnt == ES_LENGTH + 1) {503 inputobject.flags = 1;504 inputobject.timeMs = 0;505 inputobject.length = 0;506 sawInputEOS = true;507 } else {508 console.info("case read frame from file");509 inputobject.timeMs = timestamp;510 inputobject.offset = 0;511 inputobject.length = ES[frameCnt];512 getContent(inputobject.data, ES[frameCnt]);513 inputobject.flags = 0;514 }515 timestamp += ES[frameCnt]/samplerate;516 frameCnt += 1;517 audioDecodeProcessor.pushInputData(inputobject).then(() => {518 console.info('case queueInput success');519 });520 }521 }522 async function dequeueAllOutputs(queue, savapath, done) {523 while (queue.length > 0 && !sawOutputEOS) {524 let outputobject = queue.shift();525 if (outputobject.flags == 1) {526 sawOutputEOS = true;527 if (workdoneAtEOS) {528 await doneWork();529 done();530 } else {531 console.info("sawOutputEOS = true")532 }533 }534 else{535 console.info("not last frame, continue");536 }537 audioDecodeProcessor.freeOutputBuffer(outputobject).then(() => {538 console.info('release output success');539 });540 }541 }542 function setCallback(savepath, done) {543 console.info('case callback');544 audioDecodeProcessor.on('needInputData', async(inBuffer) => {545 console.info('inputBufferAvailable');546 inputQueue.push(inBuffer);547 await enqueueAllInputs(inputQueue);548 });549 audioDecodeProcessor.on('newOutputData', async(outBuffer) => {550 console.info('outputBufferAvailable');551 if (needGetMediaDes) {552 audioDecodeProcessor.getOutputMediaDescription().then((MediaDescription) => {553 console.info("get OutputMediaDescription success");554 console.info('get outputMediaDescription : ' + MediaDescription);555 needGetMediaDes=false;556 }, failCallback).catch(failCatch);}557 outputQueue.push(outBuffer);558 await dequeueAllOutputs(outputQueue, savepath, done);559 });560 audioDecodeProcessor.on('error',(err) => {561 console.info('case error called,errName is' + err);562 });563 audioDecodeProcessor.on('streamChanged',(format) => {564 console.info('Output format changed: ' + format);565 });566 }567 /* *568 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0100569 * @tc.name : 001.create -> configure570 * @tc.desc : Reliability Test571 * @tc.size : MediumTest572 * @tc.type : Reliability573 * @tc.level : Level2574 */575 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0100', 0, async function (done) {576 let savepath = BASIC_PATH + 'configure_0100.pcm';577 let mySteps = new Array(CONFIGURE, END);578 createAudioDecoder(savepath, mySteps, done);579 })580 /* *581 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0200582 * @tc.name : 002.prepare -> configure583 * @tc.desc : Reliability Test584 * @tc.size : MediumTest585 * @tc.type : Reliability586 * @tc.level : Level2587 */588 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0200', 0, async function (done) {589 let savepath = BASIC_PATH + 'configure_0200.pcm';590 let mySteps = new Array(CONFIGURE, PREPARE, CONFIGURE_ERROR, END);591 createAudioDecoder(savepath, mySteps, done);592 })593 /* *594 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0300595 * @tc.name : 003.start -> configure596 * @tc.desc : Reliability Test597 * @tc.size : MediumTest598 * @tc.type : Reliability599 * @tc.level : Level2600 */601 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0300', 0, async function (done) {602 let savepath = BASIC_PATH + 'configure_0300.pcm';603 let mySteps = new Array(CONFIGURE, PREPARE, START, CONFIGURE_ERROR, END);604 createAudioDecoder(savepath, mySteps, done);605 })606 /* *607 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0400608 * @tc.name : 004.flush -> configure609 * @tc.desc : Reliability Test610 * @tc.size : MediumTest611 * @tc.type : Reliability612 * @tc.level : Level2613 */614 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0400', 0, async function (done) {615 let savepath = BASIC_PATH + 'configure_0400.pcm';616 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, CONFIGURE_ERROR, END);617 createAudioDecoder(savepath, mySteps, done);618 })619 /* *620 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0500621 * @tc.name : 005.stop -> configure622 * @tc.desc : Reliability Test623 * @tc.size : MediumTest624 * @tc.type : Reliability625 * @tc.level : Level2626 */627 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0500', 0, async function (done) {628 let savepath = BASIC_PATH + 'configure_0500.pcm';629 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP ,CONFIGURE_ERROR, END);630 createAudioDecoder(savepath, mySteps, done);631 })632 /* *633 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0600634 * @tc.name : 006.EOS -> configure635 * @tc.desc : Reliability Test636 * @tc.size : MediumTest637 * @tc.type : Reliability638 * @tc.level : Level2639 */640 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0600', 0, async function (done) {641 let savepath = BASIC_PATH + 'configure_0600.pcm';642 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, CONFIGURE_ERROR, END);643 EOSFrameNum = 2;644 createAudioDecoder(savepath, mySteps, done);645 })646 /* *647 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0700648 * @tc.name : 007.reset -> configure649 * @tc.desc : Reliability Test650 * @tc.size : MediumTest651 * @tc.type : Reliability652 * @tc.level : Level2653 */654 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0700', 0, async function (done) {655 let savepath = BASIC_PATH + 'configure_0700.pcm';656 let mySteps = new Array(RESET, CONFIGURE, END);657 createAudioDecoder(savepath, mySteps, done);658 })659 /* *660 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0800661 * @tc.name : 008.configure -> configure662 * @tc.desc : Reliability Test663 * @tc.size : MediumTest664 * @tc.type : Reliability665 * @tc.level : Level2666 */667 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0800', 0, async function (done) {668 let savepath = BASIC_PATH + 'configure_0800.pcm';669 let mySteps = new Array(CONFIGURE, CONFIGURE_ERROR, END);670 createAudioDecoder(savepath, mySteps, done);671 })672 /* *673 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0900674 * @tc.name : 009.configure -> reset -> configure675 * @tc.desc : Reliability Test676 * @tc.size : MediumTest677 * @tc.type : Reliability678 * @tc.level : Level2679 */680 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_PROMISE_0900', 0, async function (done) {681 let savepath = BASIC_PATH + 'configure_0900.pcm';682 let mySteps = new Array(CONFIGURE, RESET, CONFIGURE, END);683 createAudioDecoder(savepath, mySteps, done);684 })685 /* *686 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0100687 * @tc.name : 001.create -> prepare688 * @tc.desc : Reliability Test689 * @tc.size : MediumTest690 * @tc.type : Reliability691 * @tc.level : Level2692 */693 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0100', 0, async function (done) {694 let savepath = BASIC_PATH + 'prepare_0100.pcm';695 let mySteps = new Array(PREPARE_ERROR, END);696 createAudioDecoder(savepath, mySteps, done);697 })698 /* *699 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0200700 * @tc.name : 002.configure -> prepare701 * @tc.desc : Reliability Test702 * @tc.size : MediumTest703 * @tc.type : Reliability704 * @tc.level : Level2705 */706 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0200', 0, async function (done) {707 let savepath = BASIC_PATH + 'prepare_0200.pcm';708 let mySteps = new Array(CONFIGURE, PREPARE, END);709 createAudioDecoder(savepath, mySteps, done);710 })711 /* *712 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0300713 * @tc.name : 003.prepare -> prepare714 * @tc.desc : Reliability Test715 * @tc.size : MediumTest716 * @tc.type : Reliability717 * @tc.level : Level2718 */719 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0300', 0, async function (done) {720 let savepath = BASIC_PATH + 'prepare_0300.pcm';721 let mySteps = new Array(CONFIGURE, PREPARE, PREPARE_ERROR, END);722 createAudioDecoder(savepath, mySteps, done);723 })724 /* *725 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0400726 * @tc.name : 004.start -> prepare727 * @tc.desc : Reliability Test728 * @tc.size : MediumTest729 * @tc.type : Reliability730 * @tc.level : Level2731 */732 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0400', 0, async function (done) {733 let savepath = BASIC_PATH + 'prepare_0400.pcm';734 let mySteps = new Array(CONFIGURE, PREPARE, START, PREPARE_ERROR, END);735 createAudioDecoder(savepath, mySteps, done);736 })737 /* *738 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0500739 * @tc.name : 005.flush -> prepare740 * @tc.desc : Reliability Test741 * @tc.size : MediumTest742 * @tc.type : Reliability743 * @tc.level : Level2744 */745 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0500', 0, async function (done) {746 let savepath = BASIC_PATH + 'prepare_0500.pcm';747 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, PREPARE_ERROR, END);748 createAudioDecoder(savepath, mySteps, done);749 })750 /* *751 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0600752 * @tc.name : 006.stop -> prepare753 * @tc.desc : Reliability Test754 * @tc.size : MediumTest755 * @tc.type : Reliability756 * @tc.level : Level2757 */758 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0600', 0, async function (done) {759 let savepath = BASIC_PATH + 'prepare_0600.pcm';760 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, PREPARE_ERROR, END);761 createAudioDecoder(savepath, mySteps, done);762 })763 /* *764 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0700765 * @tc.name : 007.EOS -> prepare766 * @tc.desc : Reliability Test767 * @tc.size : MediumTest768 * @tc.type : Reliability769 * @tc.level : Level2770 */771 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0700', 0, async function (done) {772 let savepath = BASIC_PATH + 'prepare_0700.pcm';773 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, PREPARE_ERROR, END);774 EOSFrameNum = 2;775 createAudioDecoder(savepath, mySteps, done);776 })777 /* *778 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0800779 * @tc.name : 008.reset -> prepare780 * @tc.desc : Reliability Test781 * @tc.size : MediumTest782 * @tc.type : Reliability783 * @tc.level : Level2784 */785 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_PROMISE_0800', 0, async function (done) {786 let savepath = BASIC_PATH + 'prepare_0800.pcm';787 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, PREPARE_ERROR, END);788 createAudioDecoder(savepath, mySteps, done);789 })790 /* *791 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0100792 * @tc.name : 001.create -> start793 * @tc.desc : Reliability Test794 * @tc.size : MediumTest795 * @tc.type : Reliability796 * @tc.level : Level2797 */798 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0100', 0, async function (done) {799 let savepath = BASIC_PATH + 'start_0100.pcm';800 let mySteps = new Array(START_ERROR, END);801 createAudioDecoder(savepath, mySteps, done);802 })803 /* *804 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0200805 * @tc.name : 002.configure -> start806 * @tc.desc : Reliability Test807 * @tc.size : MediumTest808 * @tc.type : Reliability809 * @tc.level : Level2810 */811 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0200', 0, async function (done) {812 let savepath = BASIC_PATH + 'start_0200.pcm';813 let mySteps = new Array(CONFIGURE, START_ERROR, END);814 createAudioDecoder(savepath, mySteps, done);815 })816 /* *817 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0300818 * @tc.name : 003.prepare -> start819 * @tc.desc : Reliability Test820 * @tc.size : MediumTest821 * @tc.type : Reliability822 * @tc.level : Level2823 */824 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0300', 0, async function (done) {825 let savepath = BASIC_PATH + 'start_0300.pcm';826 let mySteps = new Array(CONFIGURE, PREPARE, START, WAITFORALLOUTS);827 workdoneAtEOS = true;828 createAudioDecoder(savepath, mySteps, done);829 })830 /* *831 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0400832 * @tc.name : 004.start -> start833 * @tc.desc : Reliability Test834 * @tc.size : MediumTest835 * @tc.type : Reliability836 * @tc.level : Level2837 */838 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0400', 0, async function (done) {839 let savepath = BASIC_PATH + 'start_0400.pcm';840 let mySteps = new Array(CONFIGURE, PREPARE, START, START_ERROR, END);841 createAudioDecoder(savepath, mySteps, done);842 })843 /* *844 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0500845 * @tc.name : 005.flush -> start846 * @tc.desc : Reliability Test847 * @tc.size : MediumTest848 * @tc.type : Reliability849 * @tc.level : Level2850 */851 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0500', 0, async function (done) {852 let savepath = BASIC_PATH + 'start_0500.pcm';853 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END);854 createAudioDecoder(savepath, mySteps, done);855 })856 /* *857 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0600858 * @tc.name : 006.stop -> start859 * @tc.desc : Reliability Test860 * @tc.size : MediumTest861 * @tc.type : Reliability862 * @tc.level : Level2863 */864 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0600', 0, async function (done) {865 let savepath = BASIC_PATH + 'start_0600.pcm';866 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, START, WAITFORALLOUTS);867 workdoneAtEOS = true;868 createAudioDecoder(savepath, mySteps, done);869 })870 /* *871 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0700872 * @tc.name : 007.EOS -> start873 * @tc.desc : Reliability Test874 * @tc.size : MediumTest875 * @tc.type : Reliability876 * @tc.level : Level2877 */878 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0700', 0, async function (done) {879 let savepath = BASIC_PATH + 'start_0700.pcm';880 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, START_ERROR, END);881 EOSFrameNum = 2;882 createAudioDecoder(savepath, mySteps, done);883 })884 /* *885 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0800886 * @tc.name : 008.reset -> start887 * @tc.desc : Reliability Test888 * @tc.size : MediumTest889 * @tc.type : Reliability890 * @tc.level : Level2891 */892 it('SUB_MEDIA_AUDIO_DECODER_API_START_PROMISE_0800', 0, async function (done) {893 let savepath = BASIC_PATH + 'start_0800.pcm';894 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, START_ERROR, END);895 createAudioDecoder(savepath, mySteps, done);896 })897 /* *898 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0100899 * @tc.name : 001.create -> flush900 * @tc.desc : Reliability Test901 * @tc.size : MediumTest902 * @tc.type : Reliability903 * @tc.level : Level2904 */905 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0100', 0, async function (done) {906 let savepath = BASIC_PATH + 'flush_0100.pcm';907 let mySteps = new Array(FLUSH_ERROR, END);908 createAudioDecoder(savepath, mySteps, done);909 })910 /* *911 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0200912 * @tc.name : 002.configure -> flush913 * @tc.desc : Reliability Test914 * @tc.size : MediumTest915 * @tc.type : Reliability916 * @tc.level : Level2917 */918 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0200', 0, async function (done) {919 let savepath = BASIC_PATH + 'flush_0200.pcm';920 let mySteps = new Array(CONFIGURE, FLUSH_ERROR, END);921 createAudioDecoder(savepath, mySteps, done);922 })923 /* *924 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0300925 * @tc.name : 003.prepare -> flush926 * @tc.desc : Reliability Test927 * @tc.size : MediumTest928 * @tc.type : Reliability929 * @tc.level : Level2930 */931 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0300', 0, async function (done) {932 let savepath = BASIC_PATH + 'flush_0300.pcm';933 let mySteps = new Array(CONFIGURE, PREPARE, FLUSH_ERROR, END);934 createAudioDecoder(savepath, mySteps, done);935 })936 /* *937 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0400938 * @tc.name : 004.start -> flush939 * @tc.desc : Reliability Test940 * @tc.size : MediumTest941 * @tc.type : Reliability942 * @tc.level : Level2943 */944 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0400', 0, async function (done) {945 let savepath = BASIC_PATH + 'flush_0400.pcm';946 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS);947 workdoneAtEOS = true;948 createAudioDecoder(savepath, mySteps, done);949 })950 /* *951 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0500952 * @tc.name : 005.flush -> flush953 * @tc.desc : Reliability Test954 * @tc.size : MediumTest955 * @tc.type : Reliability956 * @tc.level : Level2957 */958 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0500', 0, async function (done) {959 let savepath = BASIC_PATH + 'flush_0500.pcm';960 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS);961 workdoneAtEOS = true;962 createAudioDecoder(savepath, mySteps, done);963 })964 /* *965 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0600966 * @tc.name : 006.stop -> flush967 * @tc.desc : Reliability Test968 * @tc.size : MediumTest969 * @tc.type : Reliability970 * @tc.level : Level2971 */972 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0600', 0, async function (done) {973 let savepath = BASIC_PATH + 'flush_0600.pcm';974 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP ,FLUSH_ERROR, END);975 createAudioDecoder(savepath, mySteps, done);976 })977 /* *978 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0700979 * @tc.name : 007.EOS -> flush980 * @tc.desc : Reliability Test981 * @tc.size : MediumTest982 * @tc.type : Reliability983 * @tc.level : Level2984 */985 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0700', 0, async function (done) {986 let savepath = BASIC_PATH + 'flush_0700.pcm';987 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, END);988 EOSFrameNum = 2;989 createAudioDecoder(savepath, mySteps, done);990 })991 /* *992 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0800993 * @tc.name : 008.reset -> flush994 * @tc.desc : Reliability Test995 * @tc.size : MediumTest996 * @tc.type : Reliability997 * @tc.level : Level2998 */999 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_PROMISE_0800', 0, async function (done) {1000 let savepath = BASIC_PATH + 'flush_0800.pcm';1001 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, FLUSH_ERROR, END);1002 createAudioDecoder(savepath, mySteps, done);1003 })1004 /* *1005 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_01001006 * @tc.name : 001.create -> stop1007 * @tc.desc : Reliability Test1008 * @tc.size : MediumTest1009 * @tc.type : Reliability1010 * @tc.level : Level21011 */1012 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0100', 0, async function (done) {1013 let savepath = BASIC_PATH + 'stop_0100.pcm';1014 let mySteps = new Array(STOP_ERROR, END);1015 createAudioDecoder(savepath, mySteps, done);1016 })1017 /* *1018 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_02001019 * @tc.name : 002.configure -> stop1020 * @tc.desc : Reliability Test1021 * @tc.size : MediumTest1022 * @tc.type : Reliability1023 * @tc.level : Level21024 */1025 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0200', 0, async function (done) {1026 let savepath = BASIC_PATH + 'stop_0200.pcm';1027 let mySteps = new Array(CONFIGURE, STOP_ERROR, END);1028 createAudioDecoder(savepath, mySteps, done);1029 })1030 /* *1031 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_03001032 * @tc.name : 003.prepare -> stop1033 * @tc.desc : Reliability Test1034 * @tc.size : MediumTest1035 * @tc.type : Reliability1036 * @tc.level : Level21037 */1038 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0300', 0, async function (done) {1039 let savepath = BASIC_PATH + 'stop_0300.pcm';1040 let mySteps = new Array(CONFIGURE, PREPARE, STOP_ERROR, END);1041 createAudioDecoder(savepath, mySteps, done);1042 })1043 /* *1044 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_04001045 * @tc.name : 004.start -> stop1046 * @tc.desc : Reliability Test1047 * @tc.size : MediumTest1048 * @tc.type : Reliability1049 * @tc.level : Level21050 */1051 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0400', 0, async function (done) {1052 let savepath = BASIC_PATH + 'stop_0400.pcm';1053 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, END);1054 createAudioDecoder(savepath, mySteps, done);1055 })1056 /* *1057 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_05001058 * @tc.name : 005.flush -> stop1059 * @tc.desc : Reliability Test1060 * @tc.size : MediumTest1061 * @tc.type : Reliability1062 * @tc.level : Level21063 */1064 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0500', 0, async function (done) {1065 let savepath = BASIC_PATH + 'stop_0500.pcm';1066 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, STOP, END);1067 createAudioDecoder(savepath, mySteps, done);1068 })1069 /* *1070 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_06001071 * @tc.name : 006.stop -> stop1072 * @tc.desc : Reliability Test1073 * @tc.size : MediumTest1074 * @tc.type : Reliability1075 * @tc.level : Level21076 */1077 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0600', 0, async function (done) {1078 let savepath = BASIC_PATH + 'stop_0600.pcm';1079 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, STOP_ERROR, END);1080 createAudioDecoder(savepath, mySteps, done);1081 })1082 /* *1083 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_07001084 * @tc.name : 007.EOS -> stop1085 * @tc.desc : Reliability Test1086 * @tc.size : MediumTest1087 * @tc.type : Reliability1088 * @tc.level : Level21089 */1090 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0700', 0, async function (done) {1091 let savepath = BASIC_PATH + 'stop_0700.pcm';1092 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, END);1093 EOSFrameNum = 2;1094 createAudioDecoder(savepath, mySteps, done);1095 })1096 /* *1097 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_08001098 * @tc.name : 008.reset -> stop1099 * @tc.desc : Reliability Test1100 * @tc.size : MediumTest1101 * @tc.type : Reliability1102 * @tc.level : Level21103 */1104 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_PROMISE_0800', 0, async function (done) {1105 let savepath = BASIC_PATH + 'stop_0800.pcm';1106 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, STOP_ERROR, END);1107 createAudioDecoder(savepath, mySteps, done);1108 })1109 /* *1110 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_01001111 * @tc.name : 001.create -> reset1112 * @tc.desc : Reliability Test1113 * @tc.size : MediumTest1114 * @tc.type : Reliability1115 * @tc.level : Level21116 */1117 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0100', 0, async function (done) {1118 let savepath = BASIC_PATH + 'reset_0100.pcm';1119 let mySteps = new Array(RESET, END);1120 createAudioDecoder(savepath, mySteps, done);1121 })1122 /* *1123 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_02001124 * @tc.name : 002.configure -> reset1125 * @tc.desc : Reliability Test1126 * @tc.size : MediumTest1127 * @tc.type : Reliability1128 * @tc.level : Level21129 */1130 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0200', 0, async function (done) {1131 let savepath = BASIC_PATH + 'reset_0200.pcm';1132 let mySteps = new Array(CONFIGURE, RESET, END);1133 createAudioDecoder(savepath, mySteps, done);1134 })1135 /* *1136 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_03001137 * @tc.name : 003.prepare -> reset1138 * @tc.desc : Reliability Test1139 * @tc.size : MediumTest1140 * @tc.type : Reliability1141 * @tc.level : Level21142 */1143 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0300', 0, async function (done) {1144 let savepath = BASIC_PATH + 'reset_0300.pcm';1145 let mySteps = new Array(CONFIGURE, PREPARE, RESET, END);1146 createAudioDecoder(savepath, mySteps, done);1147 })1148 /* *1149 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_04001150 * @tc.name : 004.start -> reset1151 * @tc.desc : Reliability Test1152 * @tc.size : MediumTest1153 * @tc.type : Reliability1154 * @tc.level : Level21155 */1156 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0400', 0, async function (done) {1157 let savepath = BASIC_PATH + 'reset_0400.pcm';1158 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, END);1159 createAudioDecoder(savepath, mySteps, done);1160 })1161 /* *1162 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_05001163 * @tc.name : 005.flush -> reset1164 * @tc.desc : Reliability Test1165 * @tc.size : MediumTest1166 * @tc.type : Reliability1167 * @tc.level : Level21168 */1169 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0500', 0, async function (done) {1170 let savepath = BASIC_PATH + 'reset_0500.pcm';1171 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, RESET, END);1172 createAudioDecoder(savepath, mySteps, done);1173 })1174 /* *1175 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_06001176 * @tc.name : 006.stop -> reset1177 * @tc.desc : Reliability Test1178 * @tc.size : MediumTest1179 * @tc.type : Reliability1180 * @tc.level : Level21181 */1182 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0600', 0, async function (done) {1183 let savepath = BASIC_PATH + 'reset_0600.pcm';1184 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, RESET, END);1185 createAudioDecoder(savepath, mySteps, done);1186 })1187 /* *1188 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_07001189 * @tc.name : 007.EOS -> reset1190 * @tc.desc : Reliability Test1191 * @tc.size : MediumTest1192 * @tc.type : Reliability1193 * @tc.level : Level21194 */1195 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0700', 0, async function (done) {1196 let savepath = BASIC_PATH + 'reset_0700.pcm';1197 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, RESET, END);1198 EOSFrameNum = 2;1199 createAudioDecoder(savepath, mySteps, done);1200 })1201 /* *1202 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_08001203 * @tc.name : 008.reset -> reset1204 * @tc.desc : Reliability Test1205 * @tc.size : MediumTest1206 * @tc.type : Reliability1207 * @tc.level : Level21208 */1209 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_PROMISE_0800', 0, async function (done) {1210 let savepath = BASIC_PATH + 'reset_0800.pcm';1211 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, RESET, END);1212 createAudioDecoder(savepath, mySteps, done);1213 })1214 /* *1215 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_01001216 * @tc.name : 001.EOS -> flush -> stop1217 * @tc.desc : Reliability Test1218 * @tc.size : MediumTest1219 * @tc.type : Reliability1220 * @tc.level : Level21221 */1222 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_0100', 0, async function (done) {1223 let savepath = BASIC_PATH + 'eos_0100.pcm';1224 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, FLUSH, STOP, END);1225 EOSFrameNum = 2;1226 createAudioDecoder(savepath, mySteps, done);1227 })1228 /* *1229 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_02001230 * @tc.name : 002.EOS -> flush -> EOS1231 * @tc.desc : Reliability Test1232 * @tc.size : MediumTest1233 * @tc.type : Reliability1234 * @tc.level : Level21235 */1236 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_0200', 0, async function (done) {1237 let savepath = BASIC_PATH + 'eos_0200.pcm';1238 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, FLUSH, END);1239 EOSFrameNum = 2;1240 flushAtEOS = true;1241 createAudioDecoder(savepath, mySteps, done);1242 })1243 /* *1244 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_03001245 * @tc.name : 003.EOS -> reset -> configure1246 * @tc.desc : Reliability Test1247 * @tc.size : MediumTest1248 * @tc.type : Reliability1249 * @tc.level : Level21250 */1251 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_0300', 0, async function (done) {1252 let savepath = BASIC_PATH + 'eos_0300.pcm';1253 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, RESET, CONFIGURE, END);1254 EOSFrameNum = 2;1255 createAudioDecoder(savepath, mySteps, done);1256 })1257 /* *1258 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_04001259 * @tc.name : 004.EOS -> stop -> start -> EOS1260 * @tc.desc : Reliability Test1261 * @tc.size : MediumTest1262 * @tc.type : Reliability1263 * @tc.level : Level21264 */1265 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_0400', 0, async function (done) {1266 let savepath = BASIC_PATH + 'eos_0400.pcm';1267 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, START, END);1268 EOSFrameNum = 2;1269 createAudioDecoder(savepath, mySteps, done);1270 })1271 /* *1272 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_05001273 * @tc.name : 005.EOS -> stop -> start -> stop1274 * @tc.desc : Reliability Test1275 * @tc.size : MediumTest1276 * @tc.type : Reliability1277 * @tc.level : Level21278 */1279 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_PROMISE_0500', 0, async function (done) {1280 let savepath = BASIC_PATH + 'eos_0500.pcm';1281 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, START, STOP, END);1282 EOSFrameNum = 2;1283 createAudioDecoder(savepath, mySteps, done);1284 })...

Full Screen

Full Screen

AudioDecoderReliabilityCallbackTest.test.js

Source:AudioDecoderReliabilityCallbackTest.test.js Github

copy

Full Screen

...282 sawOutputEOS = false;283 inputQueue = [];284 outputQueue = [];285 }286 async function createAudioDecoder(savepath, mySteps, done) {287 await getFdRead(AUDIOPATH, done);288 media.createAudioDecoderByMime(mime, (err, processor) => {289 expect(err).assertUndefined();290 console.info(`case createAudioDecoder 1`);291 audioDecodeProcessor = processor;292 setCallback(savepath, done);293 console.info("case start api test");294 nextStep(mySteps, mediaDescription, done);295 })296 }297 async function getFdRead(pathName, done) {298 await getFileDescriptor(pathName).then((res) => {299 if (res == undefined) {300 expect().assertFail();301 console.info('case error fileDescriptor undefined, open file fail');302 done();303 } else {304 fdRead = res.fd;305 console.info("case fdRead is: " + fdRead);306 }307 })308 }309 function readFile(path) {310 console.info('case read file start execution');311 try{312 console.info('case filepath: ' + path);313 readStreamSync = fileio.fdopenStreamSync(fdRead, 'rb');314 }catch(e) {315 console.info(e);316 }317 }318 function getContent(buf, len) {319 console.info("case start get content");320 let lengthreal = -1;321 lengthreal = readStreamSync.readSync(buf,{length:len});322 console.info('case lengthreal is :' + lengthreal);323 }324 async function doneWork(done) {325 audioDecodeProcessor.stop((err) => {326 expect(err).assertUndefined();327 console.info("case stop success");328 resetParam();329 audioDecodeProcessor.reset((err) => {330 expect(err).assertUndefined();331 console.log("case reset success");332 audioDecodeProcessor.release((err) => {333 expect(err).assertUndefined();334 console.log("case release success");335 audioDecodeProcessor = null;336 done();337 })338 })339 })340 }341 function sleep(time) {342 return new Promise((resolve) => setTimeout(resolve, time));343 }344 function wait(time) {345 for(let t = Date.now(); Date.now() - t <= time;);346 }347 async function nextStep(mySteps, mediaDescription, done) {348 console.info("case myStep[0]: " + mySteps[0]);349 if (mySteps[0] == END) {350 console.info('case to done');351 audioDecodeProcessor.release((err) => {352 expect(err).assertUndefined();353 console.info(`case release 1`);354 audioDecodeProcessor = null;355 done();356 });357 }358 switch (mySteps[0]) {359 case CONFIGURE:360 mySteps.shift();361 console.info(`case to configure`);362 await getFdRead(AUDIOPATH, done);363 audioDecodeProcessor.configure(mediaDescription, (err) => {364 expect(err).assertUndefined();365 console.info(`case configure 1`);366 readFile(AUDIOPATH);367 nextStep(mySteps, mediaDescription, done);368 });369 break;370 case PREPARE:371 mySteps.shift();372 console.info(`case to prepare`);373 audioDecodeProcessor.prepare((err) => {374 expect(err).assertUndefined();375 console.info(`case prepare 1`);376 nextStep(mySteps, mediaDescription, done);377 });378 break;379 case START:380 mySteps.shift();381 console.info(`case to start`);382 if (sawOutputEOS) {383 resetParam();384 await closeFileDescriptor(AUDIOPATH);385 await getFdRead(AUDIOPATH, done);386 readFile(AUDIOPATH);387 workdoneAtEOS = true;388 enqueueAllInputs(inputQueue);389 }390 audioDecodeProcessor.start((err) => {391 expect(err).assertUndefined();392 console.info(`case start 1`);393 nextStep(mySteps, mediaDescription, done);394 });395 break;396 case FLUSH:397 mySteps.shift();398 console.info(`case to flush`);399 inputQueue = [];400 outputQueue = [];401 audioDecodeProcessor.flush(async(err) => {402 expect(err).assertUndefined();403 console.info(`case flush 1`);404 if (flushAtEOS) {405 resetParam();406 await closeFileDescriptor(AUDIOPATH);407 await getFdRead(AUDIOPATH, done);408 readFile(AUDIOPATH);409 workdoneAtEOS = true;410 flushAtEOS = false;411 }412 nextStep(mySteps, mediaDescription, done);413 });414 break;415 case STOP:416 mySteps.shift();417 console.info(`case to stop`);418 audioDecodeProcessor.stop((err) => {419 expect(err).assertUndefined();420 console.info(`case stop 1`);421 nextStep(mySteps, mediaDescription, done);422 });423 break;424 case RESET:425 mySteps.shift();426 console.info(`case to reset`);427 resetParam();428 audioDecodeProcessor.reset((err) => {429 expect(err).assertUndefined();430 console.info(`case reset 1`);431 nextStep(mySteps, mediaDescription, done);432 });433 break;434 case HOLDON:435 mySteps.shift();436 setTimeout(() =>{437 nextStep(mySteps, mediaDescription, done);438 }, WAITTIME);439 break;440 case WAITFORALLOUTS:441 mySteps.shift();442 console.info(`case wait for all outputs`);443 break;444 case CONFIGURE_ERROR:445 mySteps.shift();446 console.info(`case to configure 2`);447 audioDecodeProcessor.configure(mediaDescription, (err) => {448 expect(err != undefined).assertTrue();449 console.info(`case configure error 1`);450 nextStep(mySteps, mediaDescription, done);451 });452 break;453 case PREPARE_ERROR:454 mySteps.shift();455 console.info(`case to prepare`);456 audioDecodeProcessor.prepare((err) => {457 expect(err != undefined).assertTrue();458 console.info(`case prepare error 1`);459 nextStep(mySteps, mediaDescription, done);460 });461 break;462 case START_ERROR:463 mySteps.shift();464 console.info(`case to start`);465 audioDecodeProcessor.start((err) => {466 expect(err != undefined).assertTrue();467 console.info(`case start error 1`);468 nextStep(mySteps, mediaDescription, done);469 });470 break;471 case FLUSH_ERROR:472 mySteps.shift();473 console.info(`case to flush`);474 audioDecodeProcessor.flush((err) => {475 expect(err != undefined).assertTrue();476 console.info(`case flush error 1`);477 nextStep(mySteps, mediaDescription, done);478 });479 break;480 case STOP_ERROR:481 mySteps.shift();482 console.info(`case to stop`);483 audioDecodeProcessor.stop((err) => {484 expect(err != undefined).assertTrue();485 console.info(`case stop error 1`);486 nextStep(mySteps, mediaDescription, done);487 });488 break;489 case JUDGE_EOS:490 mySteps.shift();491 console.info(`case judge EOS state`);492 expect(sawOutputEOS).assertTrue();493 nextStep(mySteps, mediaDescription, done);494 break;495 default:496 break;497 }498 }499 async function enqueueAllInputs(queue) {500 while (queue.length > 0 && !sawInputEOS) {501 let inputobject = queue.shift();502 console.info("frameCnt:" + frameCnt);503 if (frameCnt == EOSFrameNum || frameCnt == ES_LENGTH + 1) {504 inputobject.flags = 1;505 inputobject.timeMs = 0;506 inputobject.length = 0;507 sawInputEOS = true;508 }509 else{510 console.info("read frame from file");511 inputobject.timeMs = timestamp;512 inputobject.offset = 0;513 inputobject.length = ES[frameCnt];514 getContent(inputobject.data, ES[frameCnt]);515 inputobject.flags = 0;516 }517 timestamp += ES[frameCnt]/samplerate;518 frameCnt += 1;519 audioDecodeProcessor.pushInputData(inputobject, () => {520 console.info('queueInput success');521 })522 }523 }524 async function dequeueAllOutputs(queue, savepath, done) {525 while (queue.length > 0 && !sawOutputEOS) {526 let outputobject = queue.shift();527 if (outputobject.flags == 1) {528 sawOutputEOS = true;529 if (workdoneAtEOS) {530 await doneWork(done);531 } else {532 console.info("sawOutputEOS = true");533 }534 }535 else{536 console.info("not last frame, continue");537 }538 audioDecodeProcessor.freeOutputBuffer(outputobject, () => {539 console.info('release output success');540 })541 }542 }543 function setCallback(savepath, done) {544 console.info('case callback');545 audioDecodeProcessor.on('needInputData', async(inBuffer) => {546 console.info('inputBufferAvailable');547 inputQueue.push(inBuffer);548 await enqueueAllInputs(inputQueue);549 });550 audioDecodeProcessor.on('newOutputData', async(outBuffer) => {551 console.info('outputBufferAvailable');552 if (needGetMediaDes) {553 audioDecodeProcessor.getOutputMediaDescription((err, MediaDescription) => {554 expect(err).assertUndefined();555 console.info("get OutputMediaDescription success");556 console.info('get outputMediaDescription : ' + MediaDescription);557 needGetMediaDes=false;558 });559 }560 outputQueue.push(outBuffer);561 await dequeueAllOutputs(outputQueue, savepath, done);562 });563 audioDecodeProcessor.on('error',(err) => {564 console.info('case error called,errName is' + err);565 });566 audioDecodeProcessor.on('streamChanged',(format) => {567 console.info('Output format changed: ' + format);568 });569 }570 /* *571 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0100572 * @tc.name : 001.create -> configure573 * @tc.desc : Reliability Test574 * @tc.size : MediumTest575 * @tc.type : Reliability576 * @tc.level : Level2577 */578 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0100', 0, async function (done) {579 let savepath = BASIC_PATH + 'configure_0100.pcm';580 let mySteps = new Array(CONFIGURE, END);581 createAudioDecoder(savepath, mySteps, done);582 })583 /* *584 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0200585 * @tc.name : 002.prepare -> configure586 * @tc.desc : Reliability Test587 * @tc.size : MediumTest588 * @tc.type : Reliability589 * @tc.level : Level2590 */591 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0200', 0, async function (done) {592 let savepath = BASIC_PATH + 'configure_0200.pcm';593 let mySteps = new Array(CONFIGURE, PREPARE, CONFIGURE_ERROR, END);594 createAudioDecoder(savepath, mySteps, done);595 })596 /* *597 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0300598 * @tc.name : 003.start -> configure599 * @tc.desc : Reliability Test600 * @tc.size : MediumTest601 * @tc.type : Reliability602 * @tc.level : Level2603 */604 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0300', 0, async function (done) {605 let savepath = BASIC_PATH + 'configure_0300.pcm';606 let mySteps = new Array(CONFIGURE, PREPARE, START, CONFIGURE_ERROR, END);607 createAudioDecoder(savepath, mySteps, done);608 })609 /* *610 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0400611 * @tc.name : 004.flush -> configure612 * @tc.desc : Reliability Test613 * @tc.size : MediumTest614 * @tc.type : Reliability615 * @tc.level : Level2616 */617 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0400', 0, async function (done) {618 let savepath = BASIC_PATH + 'configure_0400.pcm';619 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, CONFIGURE_ERROR, END);620 createAudioDecoder(savepath, mySteps, done);621 })622 /* *623 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0500624 * @tc.name : 005.stop -> configure625 * @tc.desc : Reliability Test626 * @tc.size : MediumTest627 * @tc.type : Reliability628 * @tc.level : Level2629 */630 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0500', 0, async function (done) {631 let savepath = BASIC_PATH + 'configure_0500.pcm';632 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP ,CONFIGURE_ERROR, END);633 createAudioDecoder(savepath, mySteps, done);634 })635 /* *636 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0600637 * @tc.name : 006.EOS -> configure638 * @tc.desc : Reliability Test639 * @tc.size : MediumTest640 * @tc.type : Reliability641 * @tc.level : Level2642 */643 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0600', 0, async function (done) {644 let savepath = BASIC_PATH + 'configure_0600.pcm';645 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, CONFIGURE_ERROR, END);646 EOSFrameNum = 2;647 createAudioDecoder(savepath, mySteps, done);648 })649 /* *650 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0700651 * @tc.name : 007.reset -> configure652 * @tc.desc : Reliability Test653 * @tc.size : MediumTest654 * @tc.type : Reliability655 * @tc.level : Level2656 */657 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0700', 0, async function (done) {658 let savepath = BASIC_PATH + 'configure_0700.pcm';659 let mySteps = new Array(RESET, CONFIGURE, END);660 createAudioDecoder(savepath, mySteps, done);661 })662 /* *663 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0800664 * @tc.name : 008.configure -> configure665 * @tc.desc : Reliability Test666 * @tc.size : MediumTest667 * @tc.type : Reliability668 * @tc.level : Level2669 */670 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0800', 0, async function (done) {671 let savepath = BASIC_PATH + 'configure_0800.pcm';672 let mySteps = new Array(CONFIGURE, CONFIGURE_ERROR, END);673 createAudioDecoder(savepath, mySteps, done);674 })675 /* *676 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0900677 * @tc.name : 009.configure -> reset -> configure678 * @tc.desc : Reliability Test679 * @tc.size : MediumTest680 * @tc.type : Reliability681 * @tc.level : Level2682 */683 it('SUB_MEDIA_AUDIO_DECODER_API_CONFIGURE_CALLBACK_0900', 0, async function (done) {684 let savepath = BASIC_PATH + 'configure_0900.pcm';685 let mySteps = new Array(CONFIGURE, RESET, CONFIGURE, END);686 createAudioDecoder(savepath, mySteps, done);687 })688 /* *689 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0100690 * @tc.name : 001.create -> prepare691 * @tc.desc : Reliability Test692 * @tc.size : MediumTest693 * @tc.type : Reliability694 * @tc.level : Level2695 */696 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0100', 0, async function (done) {697 let savepath = BASIC_PATH + 'prepare_0100.pcm';698 let mySteps = new Array(PREPARE_ERROR, END);699 createAudioDecoder(savepath, mySteps, done);700 })701 /* *702 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0200703 * @tc.name : 002.configure -> prepare704 * @tc.desc : Reliability Test705 * @tc.size : MediumTest706 * @tc.type : Reliability707 * @tc.level : Level2708 */709 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0200', 0, async function (done) {710 let savepath = BASIC_PATH + 'prepare_0200.pcm';711 let mySteps = new Array(CONFIGURE, PREPARE, END);712 createAudioDecoder(savepath, mySteps, done);713 })714 /* *715 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0300716 * @tc.name : 003.prepare -> prepare717 * @tc.desc : Reliability Test718 * @tc.size : MediumTest719 * @tc.type : Reliability720 * @tc.level : Level2721 */722 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0300', 0, async function (done) {723 let savepath = BASIC_PATH + 'prepare_0300.pcm';724 let mySteps = new Array(CONFIGURE, PREPARE, PREPARE_ERROR, END);725 createAudioDecoder(savepath, mySteps, done);726 })727 /* *728 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0400729 * @tc.name : 004.start -> prepare730 * @tc.desc : Reliability Test731 * @tc.size : MediumTest732 * @tc.type : Reliability733 * @tc.level : Level2734 */735 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0400', 0, async function (done) {736 let savepath = BASIC_PATH + 'prepare_0400.pcm';737 let mySteps = new Array(CONFIGURE, PREPARE, START, PREPARE_ERROR, END);738 createAudioDecoder(savepath, mySteps, done);739 })740 /* *741 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0500742 * @tc.name : 005.flush -> prepare743 * @tc.desc : Reliability Test744 * @tc.size : MediumTest745 * @tc.type : Reliability746 * @tc.level : Level2747 */748 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0500', 0, async function (done) {749 let savepath = BASIC_PATH + 'prepare_0500.pcm';750 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, PREPARE_ERROR, END);751 createAudioDecoder(savepath, mySteps, done);752 })753 /* *754 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0600755 * @tc.name : 006.stop -> prepare756 * @tc.desc : Reliability Test757 * @tc.size : MediumTest758 * @tc.type : Reliability759 * @tc.level : Level2760 */761 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0600', 0, async function (done) {762 let savepath = BASIC_PATH + 'prepare_0600.pcm';763 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, PREPARE_ERROR, END);764 createAudioDecoder(savepath, mySteps, done);765 })766 /* *767 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0700768 * @tc.name : 007.EOS -> prepare769 * @tc.desc : Reliability Test770 * @tc.size : MediumTest771 * @tc.type : Reliability772 * @tc.level : Level2773 */774 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0700', 0, async function (done) {775 let savepath = BASIC_PATH + 'prepare_0700.pcm';776 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, PREPARE_ERROR, END);777 EOSFrameNum = 2;778 createAudioDecoder(savepath, mySteps, done);779 })780 /* *781 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0800782 * @tc.name : 008.reset -> prepare783 * @tc.desc : Reliability Test784 * @tc.size : MediumTest785 * @tc.type : Reliability786 * @tc.level : Level2787 */788 it('SUB_MEDIA_AUDIO_DECODER_API_PREPARE_CALLBACK_0800', 0, async function (done) {789 let savepath = BASIC_PATH + 'prepare_0800.pcm';790 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, PREPARE_ERROR, END);791 createAudioDecoder(savepath, mySteps, done);792 })793 /* *794 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0100795 * @tc.name : 001.create -> start796 * @tc.desc : Reliability Test797 * @tc.size : MediumTest798 * @tc.type : Reliability799 * @tc.level : Level2800 */801 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0100', 0, async function (done) {802 let savepath = BASIC_PATH + 'start_0100.pcm';803 let mySteps = new Array(START_ERROR, END);804 createAudioDecoder(savepath, mySteps, done);805 })806 /* *807 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0200808 * @tc.name : 002.configure -> start809 * @tc.desc : Reliability Test810 * @tc.size : MediumTest811 * @tc.type : Reliability812 * @tc.level : Level2813 */814 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0200', 0, async function (done) {815 let savepath = BASIC_PATH + 'start_0200.pcm';816 let mySteps = new Array(CONFIGURE, START_ERROR, END);817 createAudioDecoder(savepath, mySteps, done);818 })819 /* *820 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0300821 * @tc.name : 003.prepare -> start822 * @tc.desc : Reliability Test823 * @tc.size : MediumTest824 * @tc.type : Reliability825 * @tc.level : Level2826 */827 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0300', 0, async function (done) {828 let savepath = BASIC_PATH + 'start_0300.pcm';829 let mySteps = new Array(CONFIGURE, PREPARE, START, WAITFORALLOUTS);830 workdoneAtEOS = true;831 createAudioDecoder(savepath, mySteps, done);832 })833 /* *834 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0400835 * @tc.name : 004.start -> start836 * @tc.desc : Reliability Test837 * @tc.size : MediumTest838 * @tc.type : Reliability839 * @tc.level : Level2840 */841 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0400', 0, async function (done) {842 let savepath = BASIC_PATH + 'start_0400.pcm';843 let mySteps = new Array(CONFIGURE, PREPARE, START, START_ERROR, END);844 createAudioDecoder(savepath, mySteps, done);845 })846 /* *847 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0500848 * @tc.name : 005.flush -> start849 * @tc.desc : Reliability Test850 * @tc.size : MediumTest851 * @tc.type : Reliability852 * @tc.level : Level2853 */854 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0500', 0, async function (done) {855 let savepath = BASIC_PATH + 'start_0500.pcm';856 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, START_ERROR, END);857 createAudioDecoder(savepath, mySteps, done);858 })859 /* *860 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0600861 * @tc.name : 006.stop -> start862 * @tc.desc : Reliability Test863 * @tc.size : MediumTest864 * @tc.type : Reliability865 * @tc.level : Level2866 */867 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0600', 0, async function (done) {868 let savepath = BASIC_PATH + 'start_0600.pcm';869 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, START, WAITFORALLOUTS);870 workdoneAtEOS = true;871 createAudioDecoder(savepath, mySteps, done);872 })873 /* *874 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0700875 * @tc.name : 007.EOS -> start876 * @tc.desc : Reliability Test877 * @tc.size : MediumTest878 * @tc.type : Reliability879 * @tc.level : Level2880 */881 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0700', 0, async function (done) {882 let savepath = BASIC_PATH + 'start_0700.pcm';883 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, START_ERROR, END);884 EOSFrameNum = 2;885 createAudioDecoder(savepath, mySteps, done);886 })887 /* *888 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0800889 * @tc.name : 008.reset -> start890 * @tc.desc : Reliability Test891 * @tc.size : MediumTest892 * @tc.type : Reliability893 * @tc.level : Level2894 */895 it('SUB_MEDIA_AUDIO_DECODER_API_START_CALLBACK_0800', 0, async function (done) {896 let savepath = BASIC_PATH + 'start_0800.pcm';897 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, START_ERROR, END);898 createAudioDecoder(savepath, mySteps, done);899 })900 /* *901 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0100902 * @tc.name : 001.create -> flush903 * @tc.desc : Reliability Test904 * @tc.size : MediumTest905 * @tc.type : Reliability906 * @tc.level : Level2907 */908 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0100', 0, async function (done) {909 let savepath = BASIC_PATH + 'flush_0100.pcm';910 let mySteps = new Array(FLUSH_ERROR, END);911 createAudioDecoder(savepath, mySteps, done);912 })913 /* *914 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0200915 * @tc.name : 002.configure -> flush916 * @tc.desc : Reliability Test917 * @tc.size : MediumTest918 * @tc.type : Reliability919 * @tc.level : Level2920 */921 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0200', 0, async function (done) {922 let savepath = BASIC_PATH + 'flush_0200.pcm';923 let mySteps = new Array(CONFIGURE, FLUSH_ERROR, END);924 createAudioDecoder(savepath, mySteps, done);925 })926 /* *927 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0300928 * @tc.name : 003.prepare -> flush929 * @tc.desc : Reliability Test930 * @tc.size : MediumTest931 * @tc.type : Reliability932 * @tc.level : Level2933 */934 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0300', 0, async function (done) {935 let savepath = BASIC_PATH + 'flush_0300.pcm';936 let mySteps = new Array(CONFIGURE, PREPARE, FLUSH_ERROR, END);937 createAudioDecoder(savepath, mySteps, done);938 })939 /* *940 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0400941 * @tc.name : 004.start -> flush942 * @tc.desc : Reliability Test943 * @tc.size : MediumTest944 * @tc.type : Reliability945 * @tc.level : Level2946 */947 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0400', 0, async function (done) {948 let savepath = BASIC_PATH + 'flush_0400.pcm';949 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, WAITFORALLOUTS);950 workdoneAtEOS = true;951 createAudioDecoder(savepath, mySteps, done);952 })953 /* *954 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0500955 * @tc.name : 005.flush -> flush956 * @tc.desc : Reliability Test957 * @tc.size : MediumTest958 * @tc.type : Reliability959 * @tc.level : Level2960 */961 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0500', 0, async function (done) {962 let savepath = BASIC_PATH + 'flush_0500.pcm';963 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, FLUSH, WAITFORALLOUTS);964 workdoneAtEOS = true;965 createAudioDecoder(savepath, mySteps, done);966 })967 /* *968 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0600969 * @tc.name : 006.stop -> flush970 * @tc.desc : Reliability Test971 * @tc.size : MediumTest972 * @tc.type : Reliability973 * @tc.level : Level2974 */975 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0600', 0, async function (done) {976 let savepath = BASIC_PATH + 'flush_0600.pcm';977 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP ,FLUSH_ERROR, END);978 createAudioDecoder(savepath, mySteps, done);979 })980 /* *981 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0700982 * @tc.name : 007.EOS -> flush983 * @tc.desc : Reliability Test984 * @tc.size : MediumTest985 * @tc.type : Reliability986 * @tc.level : Level2987 */988 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0700', 0, async function (done) {989 let savepath = BASIC_PATH + 'flush_0700.pcm';990 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, FLUSH, END);991 EOSFrameNum = 2;992 createAudioDecoder(savepath, mySteps, done);993 })994 /* *995 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0800996 * @tc.name : 008.reset -> flush997 * @tc.desc : Reliability Test998 * @tc.size : MediumTest999 * @tc.type : Reliability1000 * @tc.level : Level21001 */1002 it('SUB_MEDIA_AUDIO_DECODER_API_FLUSH_CALLBACK_0800', 0, async function (done) {1003 let savepath = BASIC_PATH + 'flush_0800.pcm';1004 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, FLUSH_ERROR, END);1005 createAudioDecoder(savepath, mySteps, done);1006 })1007 /* *1008 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_01001009 * @tc.name : 001.create -> stop1010 * @tc.desc : Reliability Test1011 * @tc.size : MediumTest1012 * @tc.type : Reliability1013 * @tc.level : Level21014 */1015 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0100', 0, async function (done) {1016 let savepath = BASIC_PATH + 'stop_0100.pcm';1017 let mySteps = new Array(STOP_ERROR, END);1018 createAudioDecoder(savepath, mySteps, done);1019 })1020 /* *1021 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_02001022 * @tc.name : 002.configure -> stop1023 * @tc.desc : Reliability Test1024 * @tc.size : MediumTest1025 * @tc.type : Reliability1026 * @tc.level : Level21027 */1028 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0200', 0, async function (done) {1029 let savepath = BASIC_PATH + 'stop_0200.pcm';1030 let mySteps = new Array(CONFIGURE, STOP_ERROR, END);1031 createAudioDecoder(savepath, mySteps, done);1032 })1033 /* *1034 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_03001035 * @tc.name : 003.prepare -> stop1036 * @tc.desc : Reliability Test1037 * @tc.size : MediumTest1038 * @tc.type : Reliability1039 * @tc.level : Level21040 */1041 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0300', 0, async function (done) {1042 let savepath = BASIC_PATH + 'stop_0300.pcm';1043 let mySteps = new Array(CONFIGURE, PREPARE, STOP_ERROR, END);1044 createAudioDecoder(savepath, mySteps, done);1045 })1046 /* *1047 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_04001048 * @tc.name : 004.start -> stop1049 * @tc.desc : Reliability Test1050 * @tc.size : MediumTest1051 * @tc.type : Reliability1052 * @tc.level : Level21053 */1054 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0400', 0, async function (done) {1055 let savepath = BASIC_PATH + 'stop_0400.pcm';1056 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, END);1057 createAudioDecoder(savepath, mySteps, done);1058 })1059 /* *1060 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_05001061 * @tc.name : 005.flush -> stop1062 * @tc.desc : Reliability Test1063 * @tc.size : MediumTest1064 * @tc.type : Reliability1065 * @tc.level : Level21066 */1067 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0500', 0, async function (done) {1068 let savepath = BASIC_PATH + 'stop_0500.pcm';1069 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, STOP, END);1070 createAudioDecoder(savepath, mySteps, done);1071 })1072 /* *1073 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_06001074 * @tc.name : 006.stop -> stop1075 * @tc.desc : Reliability Test1076 * @tc.size : MediumTest1077 * @tc.type : Reliability1078 * @tc.level : Level21079 */1080 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0600', 0, async function (done) {1081 let savepath = BASIC_PATH + 'stop_0600.pcm';1082 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, STOP_ERROR, END);1083 createAudioDecoder(savepath, mySteps, done);1084 })1085 /* *1086 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_07001087 * @tc.name : 007.EOS -> stop1088 * @tc.desc : Reliability Test1089 * @tc.size : MediumTest1090 * @tc.type : Reliability1091 * @tc.level : Level21092 */1093 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0700', 0, async function (done) {1094 let savepath = BASIC_PATH + 'stop_0700.pcm';1095 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, END);1096 EOSFrameNum = 2;1097 createAudioDecoder(savepath, mySteps, done);1098 })1099 /* *1100 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_08001101 * @tc.name : 008.reset -> stop1102 * @tc.desc : Reliability Test1103 * @tc.size : MediumTest1104 * @tc.type : Reliability1105 * @tc.level : Level21106 */1107 it('SUB_MEDIA_AUDIO_DECODER_API_STOP_CALLBACK_0800', 0, async function (done) {1108 let savepath = BASIC_PATH + 'stop_0800.pcm';1109 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, STOP_ERROR, END);1110 createAudioDecoder(savepath, mySteps, done);1111 })1112 /* *1113 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_01001114 * @tc.name : 001.create -> reset1115 * @tc.desc : Reliability Test1116 * @tc.size : MediumTest1117 * @tc.type : Reliability1118 * @tc.level : Level21119 */1120 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0100', 0, async function (done) {1121 let savepath = BASIC_PATH + 'reset_0100.pcm';1122 let mySteps = new Array(RESET, END);1123 createAudioDecoder(savepath, mySteps, done);1124 })1125 /* *1126 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_02001127 * @tc.name : 002.configure -> reset1128 * @tc.desc : Reliability Test1129 * @tc.size : MediumTest1130 * @tc.type : Reliability1131 * @tc.level : Level21132 */1133 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0200', 0, async function (done) {1134 let savepath = BASIC_PATH + 'reset_0200.pcm';1135 let mySteps = new Array(CONFIGURE, RESET, END);1136 createAudioDecoder(savepath, mySteps, done);1137 })1138 /* *1139 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_03001140 * @tc.name : 003.prepare -> reset1141 * @tc.desc : Reliability Test1142 * @tc.size : MediumTest1143 * @tc.type : Reliability1144 * @tc.level : Level21145 */1146 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0300', 0, async function (done) {1147 let savepath = BASIC_PATH + 'reset_0300.pcm';1148 let mySteps = new Array(CONFIGURE, PREPARE, RESET, END);1149 createAudioDecoder(savepath, mySteps, done);1150 })1151 /* *1152 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_04001153 * @tc.name : 004.start -> reset1154 * @tc.desc : Reliability Test1155 * @tc.size : MediumTest1156 * @tc.type : Reliability1157 * @tc.level : Level21158 */1159 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0400', 0, async function (done) {1160 let savepath = BASIC_PATH + 'reset_0400.pcm';1161 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, END);1162 createAudioDecoder(savepath, mySteps, done);1163 })1164 /* *1165 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_05001166 * @tc.name : 005.flush -> reset1167 * @tc.desc : Reliability Test1168 * @tc.size : MediumTest1169 * @tc.type : Reliability1170 * @tc.level : Level21171 */1172 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0500', 0, async function (done) {1173 let savepath = BASIC_PATH + 'reset_0500.pcm';1174 let mySteps = new Array(CONFIGURE, PREPARE, START, FLUSH, RESET, END);1175 createAudioDecoder(savepath, mySteps, done);1176 })1177 /* *1178 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_06001179 * @tc.name : 006.stop -> reset1180 * @tc.desc : Reliability Test1181 * @tc.size : MediumTest1182 * @tc.type : Reliability1183 * @tc.level : Level21184 */1185 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0600', 0, async function (done) {1186 let savepath = BASIC_PATH + 'reset_0600.pcm';1187 let mySteps = new Array(CONFIGURE, PREPARE, START, STOP, RESET, END);1188 createAudioDecoder(savepath, mySteps, done);1189 })1190 /* *1191 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_07001192 * @tc.name : 007.EOS -> reset1193 * @tc.desc : Reliability Test1194 * @tc.size : MediumTest1195 * @tc.type : Reliability1196 * @tc.level : Level21197 */1198 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0700', 0, async function (done) {1199 let savepath = BASIC_PATH + 'reset_0700.pcm';1200 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, RESET, END);1201 EOSFrameNum = 2;1202 createAudioDecoder(savepath, mySteps, done);1203 })1204 /* *1205 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_08001206 * @tc.name : 008.reset -> reset1207 * @tc.desc : Reliability Test1208 * @tc.size : MediumTest1209 * @tc.type : Reliability1210 * @tc.level : Level21211 */1212 it('SUB_MEDIA_AUDIO_DECODER_API_RESET_CALLBACK_0800', 0, async function (done) {1213 let savepath = BASIC_PATH + 'reset_0800.pcm';1214 let mySteps = new Array(CONFIGURE, PREPARE, START, RESET, RESET, END);1215 createAudioDecoder(savepath, mySteps, done);1216 })1217 /* *1218 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_01001219 * @tc.name : 001.EOS -> flush -> stop1220 * @tc.desc : Reliability Test1221 * @tc.size : MediumTest1222 * @tc.type : Reliability1223 * @tc.level : Level21224 */1225 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_0100', 0, async function (done) {1226 let savepath = BASIC_PATH + 'eos_0100.pcm';1227 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, FLUSH, STOP, END);1228 EOSFrameNum = 2;1229 createAudioDecoder(savepath, mySteps, done);1230 })1231 /* *1232 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_02001233 * @tc.name : 002.EOS -> flush -> EOS1234 * @tc.desc : Reliability Test1235 * @tc.size : MediumTest1236 * @tc.type : Reliability1237 * @tc.level : Level21238 */1239 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_0200', 0, async function (done) {1240 let savepath = BASIC_PATH + 'eos_0200.pcm';1241 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, FLUSH, END);1242 EOSFrameNum = 2;1243 flushAtEOS = true;1244 createAudioDecoder(savepath, mySteps, done);1245 })1246 /* *1247 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_03001248 * @tc.name : 003.EOS -> reset -> configure1249 * @tc.desc : Reliability Test1250 * @tc.size : MediumTest1251 * @tc.type : Reliability1252 * @tc.level : Level21253 */1254 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_0300', 0, async function (done) {1255 let savepath = BASIC_PATH + 'eos_0300.pcm';1256 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, RESET, CONFIGURE, END);1257 EOSFrameNum = 2;1258 createAudioDecoder(savepath, mySteps, done);1259 })1260 /* *1261 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_04001262 * @tc.name : 004.EOS -> stop -> start -> EOS1263 * @tc.desc : Reliability Test1264 * @tc.size : MediumTest1265 * @tc.type : Reliability1266 * @tc.level : Level21267 */1268 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_0400', 0, async function (done) {1269 let savepath = BASIC_PATH + 'eos_0400.pcm';1270 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, START, END);1271 EOSFrameNum = 2;1272 createAudioDecoder(savepath, mySteps, done);1273 })1274 /* *1275 * @tc.number : SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_05001276 * @tc.name : 005.EOS -> stop -> start -> stop1277 * @tc.desc : Reliability Test1278 * @tc.size : MediumTest1279 * @tc.type : Reliability1280 * @tc.level : Level21281 */1282 it('SUB_MEDIA_AUDIO_DECODER_API_EOS_CALLBACK_0500', 0, async function (done) {1283 let savepath = BASIC_PATH + 'eos_0500.pcm';1284 let mySteps = new Array(CONFIGURE, PREPARE, START, HOLDON, JUDGE_EOS, STOP, START, STOP, END);1285 EOSFrameNum = 2;1286 createAudioDecoder(savepath, mySteps, done);1287 })...

Full Screen

Full Screen

audioDecoder-codec-specific.https.any.js

Source:audioDecoder-codec-specific.https.any.js Github

copy

Full Screen

...108 duration: 35555109};110// Allows mutating `callbacks` after constructing the AudioDecoder, wraps calls111// in t.step().112function createAudioDecoder(t, callbacks) {113 return new AudioDecoder({114 output(frame) {115 if (callbacks && callbacks.output) {116 t.step(() => callbacks.output(frame));117 } else {118 t.unreached_func('unexpected output()');119 }120 },121 error(e) {122 if (callbacks && callbacks.error) {123 t.step(() => callbacks.error(e));124 } else {125 t.unreached_func('unexpected error()');126 }127 }128 });129}130// Create a view of an ArrayBuffer.131function view(buffer, {offset, size}) {132 return new Uint8Array(buffer, offset, size);133}134let CONFIG = null;135let CHUNK_DATA = null;136let CHUNKS = null;137promise_setup(async () => {138 const data = {139 '?adts_aac': ADTS_AAC_DATA,140 '?mp3': MP3_DATA,141 '?mp4_aac': MP4_AAC_DATA,142 '?opus': OPUS_DATA,143 '?pcm_alaw': PCM_ALAW_DATA,144 '?pcm_mulaw': PCM_MULAW_DATA,145 }[location.search];146 // Don't run any tests if the codec is not supported.147 let supported = false;148 try {149 const support = await AudioDecoder.isConfigSupported({150 codec: data.config.codec,151 sampleRate: data.config.sampleRate,152 numberOfChannels: data.config.numberOfChannels153 });154 supported = support.supported;155 } catch (e) {156 }157 assert_implements_optional(supported, data.config.codec + ' unsupported');158 // Fetch the media data and prepare buffers.159 const response = await fetch(data.src);160 const buf = await response.arrayBuffer();161 CONFIG = {...data.config};162 if (data.config.description) {163 CONFIG.description = view(buf, data.config.description);164 }165 CHUNK_DATA = data.chunks.map((chunk, i) => view(buf, chunk));166 CHUNKS = CHUNK_DATA.map((encodedData, i) => new EncodedAudioChunk({167 type: 'key',168 timestamp: i * data.duration,169 duration: data.duration,170 data: encodedData171 }));172});173promise_test(t => {174 return AudioDecoder.isConfigSupported(CONFIG);175}, 'Test isConfigSupported()');176promise_test(t => {177 // Define a valid config that includes a hypothetical 'futureConfigFeature',178 // which is not yet recognized by the User Agent.179 const validConfig = {180 ...CONFIG,181 futureConfigFeature: 'foo',182 };183 // The UA will evaluate validConfig as being "valid", ignoring the184 // `futureConfigFeature` it doesn't recognize.185 return AudioDecoder.isConfigSupported(validConfig).then((decoderSupport) => {186 // AudioDecoderSupport must contain the following properites.187 assert_true(decoderSupport.hasOwnProperty('supported'));188 assert_true(decoderSupport.hasOwnProperty('config'));189 // AudioDecoderSupport.config must not contain unrecognized properties.190 assert_false(decoderSupport.config.hasOwnProperty('futureConfigFeature'));191 // AudioDecoderSupport.config must contiain the recognized properties.192 assert_equals(decoderSupport.config.codec, validConfig.codec);193 assert_equals(decoderSupport.config.sampleRate, validConfig.sampleRate);194 assert_equals(195 decoderSupport.config.numberOfChannels, validConfig.numberOfChannels);196 if (validConfig.description) {197 // The description must be copied.198 assert_false(199 decoderSupport.config.description === validConfig.description,200 'description is unique');201 assert_array_equals(202 new Uint8Array(decoderSupport.config.description, 0),203 new Uint8Array(validConfig.description, 0), 'description');204 } else {205 assert_false(206 decoderSupport.config.hasOwnProperty('description'), 'description');207 }208 });209}, 'Test that AudioDecoder.isConfigSupported() returns a parsed configuration');210promise_test(async t => {211 const decoder = createAudioDecoder(t);212 decoder.configure(CONFIG);213 assert_equals(decoder.state, 'configured', 'state');214}, 'Test configure()');215promise_test(t => {216 const decoder = createAudioDecoder(t);217 return testClosedCodec(t, decoder, CONFIG, CHUNKS[0]);218}, 'Verify closed AudioDecoder operations');219promise_test(async t => {220 const callbacks = {};221 const decoder = createAudioDecoder(t, callbacks);222 let outputs = 0;223 callbacks.output = frame => {224 outputs++;225 frame.close();226 };227 decoder.configure(CONFIG);228 CHUNKS.forEach(chunk => {229 decoder.decode(chunk);230 });231 await decoder.flush();232 assert_equals(outputs, CHUNKS.length, 'outputs');233}, 'Test decoding');234promise_test(async t => {235 const callbacks = {};236 const decoder = createAudioDecoder(t, callbacks);237 let outputs = 0;238 callbacks.output = frame => {239 outputs++;240 frame.close();241 };242 decoder.configure(CONFIG);243 decoder.decode(new EncodedAudioChunk(244 {type: 'key', timestamp: -42, data: CHUNK_DATA[0]}));245 await decoder.flush();246 assert_equals(outputs, 1, 'outputs');247}, 'Test decoding a with negative timestamp');248promise_test(async t => {249 const callbacks = {};250 const decoder = createAudioDecoder(t, callbacks);251 let outputs = 0;252 callbacks.output = frame => {253 outputs++;254 frame.close();255 };256 decoder.configure(CONFIG);257 decoder.decode(CHUNKS[0]);258 await decoder.flush();259 assert_equals(outputs, 1, 'outputs');260 decoder.decode(CHUNKS[0]);261 await decoder.flush();262 assert_equals(outputs, 2, 'outputs');263}, 'Test decoding after flush');264promise_test(async t => {265 const callbacks = {};266 const decoder = createAudioDecoder(t, callbacks);267 decoder.configure(CONFIG);268 decoder.decode(CHUNKS[0]);269 decoder.decode(CHUNKS[1]);270 const flushDone = decoder.flush();271 // Wait for the first output, then reset.272 let outputs = 0;273 await new Promise(resolve => {274 callbacks.output = frame => {275 outputs++;276 assert_equals(outputs, 1, 'outputs');277 decoder.reset();278 frame.close();279 resolve();280 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var decoder = wpt.createAudioDecoder();2decoder.decodeAudioData(audioData, successCallback, errorCallback);3var decoder = wpt.createAudioDecoder();4decoder.decodeAudioData(audioData, successCallback, errorCallback);5var decoder = wpt.createAudioDecoder();6decoder.decodeAudioData(audioData, successCallback, errorCallback);7var decoder = wpt.createAudioDecoder();8decoder.decodeAudioData(audioData, successCallback, errorCallback);9var decoder = wpt.createAudioDecoder();10decoder.decodeAudioData(audioData, successCallback, errorCallback);11var decoder = wpt.createAudioDecoder();12decoder.decodeAudioData(audioData, successCallback, errorCallback);13var decoder = wpt.createAudioDecoder();14decoder.decodeAudioData(audioData, successCallback, errorCallback);15var decoder = wpt.createAudioDecoder();16decoder.decodeAudioData(audioData, successCallback, errorCallback);17var decoder = wpt.createAudioDecoder();18decoder.decodeAudioData(audioData, successCallback, errorCallback);19var decoder = wpt.createAudioDecoder();20decoder.decodeAudioData(audioData, successCallback, errorCallback);21var decoder = wpt.createAudioDecoder();22decoder.decodeAudioData(audioData, successCallback, errorCallback);23var decoder = wpt.createAudioDecoder();24decoder.decodeAudioData(audioData, successCallback, errorCallback);25var decoder = wpt.createAudioDecoder();26decoder.decodeAudioData(audioData, successCallback, errorCallback);

Full Screen

Using AI Code Generation

copy

Full Screen

1var decoder = new AudioDecoder();2decoder.configure({3 description: new AudioDecoderConfigDescription({4 description: new AudioDecoderConfigDescription({5 description: new AudioDecoderConfigDescription({6 description: new AudioDecoderConfigDescription({7 description: new AudioDecoderConfigDescription({8 description: new AudioDecoderConfigDescription({9 description: new AudioDecoderConfigDescription({10 description: new AudioDecoderConfigDescription({11 description: new AudioDecoderConfigDescription({12 description: new AudioDecoderConfigDescription({13 description: new AudioDecoderConfigDescription({14 description: new AudioDecoderConfigDescription({15 description: new AudioDecoderConfigDescription({16 description: new AudioDecoderConfigDescription({17 description: new AudioDecoderConfigDescription({

Full Screen

Using AI Code Generation

copy

Full Screen

1function createAudioDecoder() {2 return new Promise((resolve, reject) => {3 try {4 const audioDecoder = new AudioDecoder({5 output: new AudioBufferQueue({6 }),7 error: e => {8 reject(e.error);9 }10 });11 resolve(audioDecoder);12 } catch (e) {13 reject(e);14 }15 });16}17const audioContext = new AudioContext();18const audioElement = document.querySelector("audio");19const audioBuffer = await audioContext.decodeAudioData(20 await (await fetch(audioElement.src)).arrayBuffer()21);22const audioDecoder = await createAudioDecoder();23const audioBufferQueue = audioDecoder.output;24const audioBufferSource = audioContext.createBufferSource();25audioBufferSource.buffer = audioBuffer;26audioBufferSource.connect(audioContext.destination);27audioBufferSource.start();28audioBufferQueue.onstatechange = () => {29 if (audioBufferQueue.state === "closed") {30 console.log("audioBufferQueue closed");31 }32};33audioBufferQueue.onpull = async () => {34 console.log("onpull");35 const audioBuffer = audioBufferQueue.pull();36 if (audioBuffer) {37 console.log("audioBuffer", audioBuffer);38 }39};40audioBufferQueue.onpush = () => {41 console.log("onpush");42};43const audioData = audioBuffer.getChannelData(0);44const audioDataLength = audioData.length;45const audioDataCopy = new Float32Array(audioDataLength);46audioDataCopy.set(audioData);47const audioBufferCopy = new AudioBuffer({48});49audioBufferCopy.copyToChannel(audioDataCopy, 0);50audioBufferQueue.push(audioBufferCopy);51audioBufferQueue.close();52audioDecoder.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1var decoder = new AudioDecoder(); 2decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});3decoder.close();4decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});5decoder.close();6var decoder = new AudioDecoder(); 7decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});8decoder.close();9var decoder = new AudioDecoder(); 10decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});11decoder.close();12var decoder = new AudioDecoder(); 13decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});14decoder.close();15var decoder = new AudioDecoder(); 16decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});17decoder.close();18var decoder = new AudioDecoder(); 19decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});20decoder.close();21var decoder = new AudioDecoder(); 22decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});23decoder.close();24var decoder = new AudioDecoder(); 25decoder.configure({codec: "opus", sampleRate: 48000, numberOfChannels: 2, description: null});26decoder.close();27var decoder = new AudioDecoder(); 28decoder.configure({codec: "opus", sampleRate: 480

Full Screen

Using AI Code Generation

copy

Full Screen

1const audioContext = new AudioContext();2const audioDecoder = new AudioDecoder(audioContext, {3 error: (err) => {4 console.log("Error: " + err);5 },6});7const track = new MediaStreamTrack();8const decoder = wptMediaStreamTrack.createAudioDecoder(track, audioDecoder);9const stream = new MediaStream();10stream.addTrack(track);11const source = audioContext.createMediaStreamSource(stream);12source.connect(audioContext.destination);13const source1 = audioContext.createMediaStreamSource(stream);14source1.connect(audioContext.destination);15const source2 = audioContext.createMediaStreamSource(stream);16source2.connect(audioContext.destination);17const source3 = audioContext.createMediaStreamSource(stream);18source3.connect(audioContext.destination);19const source4 = audioContext.createMediaStreamSource(stream);20source4.connect(audioContext.destination);21const source5 = audioContext.createMediaStreamSource(stream);22source5.connect(audioContext.destination);23const source6 = audioContext.createMediaStreamSource(stream);24source6.connect(audioContext.destination);25const source7 = audioContext.createMediaStreamSource(stream);26source7.connect(audioContext.destination);27const source8 = audioContext.createMediaStreamSource(stream);28source8.connect(audioContext.destination);29const source9 = audioContext.createMediaStreamSource(stream);30source9.connect(audioContext.destination);

Full Screen

Using AI Code Generation

copy

Full Screen

1var audioDecoder = createAudioDecoder();2audioDecoder.configure({codec: "mp3"});3audioDecoder.decode().then(function(result) {4 assert_equals(result.status, "end-of-stream");5 assert_equals(result.frames.length, 0);6 assert_equals(result.duration, 0);7 assert_equals(result.timestamp, 0);8 assert_equals(result.decodedFrames, 0);9}, "decode() should resolve with an empty output if called before configure()");10var audioDecoder = createAudioDecoder();11audioDecoder.configure({codec: "mp3"});12audioDecoder.decode().then(function(result) {13 assert_equals(result.status, "end-of-stream");14 assert_equals(result.frames.length, 0);15 assert_equals(result.duration, 0);16 assert_equals(result.timestamp, 0);17 assert_equals(result.decodedFrames, 0);18}, "decode() should resolve with an empty output if called before configure()");

Full Screen

Using AI Code Generation

copy

Full Screen

1var decoder = createAudioDecoder();2var decoderConfig = {3 description: {4 }5};6decoder.configure(decoderConfig);7var encoder = createAudioEncoder();8var encoderConfig = {9 description: {10 }11};12encoder.configure(encoderConfig);13var context = createAudioContext();14var source = context.createBufferSource();15var buffer = context.createBuffer(2, 1024, 48000);16source.buffer = buffer;17source.connect(context.destination);18source.start();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful