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

!5784 audio_xts整改

Merge pull request !5784 from liuxueqi/master
...@@ -99,8 +99,7 @@ describe('audioCapturerChange', function () { ...@@ -99,8 +99,7 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false; audioStreamManager.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => {
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
console.info(Tag + 'StrId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); console.info(Tag + 'StrId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId);
...@@ -120,34 +119,20 @@ describe('audioCapturerChange', function () { ...@@ -120,34 +119,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + '[CAPTURER-CHANGE-ON-001] ResultFlag for element ' + i + ' is: ' + resultFlag); await audioCap.release();
expect(true).assertTrue();
done();
} }
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { } catch (err) {
audioCap = data; console.log('err :' + JSON.stringify(err));
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); expect(false).assertTrue();
}).catch((err) => { done();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); }
});
await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-001] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -188,9 +173,7 @@ describe('audioCapturerChange', function () { ...@@ -188,9 +173,7 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message);
}); });
await sleep(100); audioStreamManagerCB.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => {
audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
console.info(Tag + 'StrId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); console.info(Tag + 'StrId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId);
...@@ -212,31 +195,24 @@ describe('audioCapturerChange', function () { ...@@ -212,31 +195,24 @@ describe('audioCapturerChange', function () {
if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) {
resultFlag = true; resultFlag = true;
console.info(Tag + '[CAPTURER-CHANGE-ON-002] ResultFlag for element ' + i + ' is: ' + resultFlag); console.info(Tag + '[CAPTURER-CHANGE-ON-002] ResultFlag for element ' + i + ' is: ' + resultFlag);
audioStreamManagerCB.off('audioCapturerChange');
console.info(Tag + '[CAPTURER-CHANGE-ON-002] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
done();
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
} }
} }
}); });
await sleep(100);
await audioCap.start().then(async function () { await audioCap.start().then(async function () {
console.info(Tag + 'Capturer started :SUCCESS '); console.info(Tag + 'Capturer started :SUCCESS ');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer start :ERROR : ' + err.message); console.info(Tag + 'Capturer start :ERROR : ' + err.message);
}); });
await sleep(100);
audioStreamManagerCB.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-002] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -457,8 +433,6 @@ describe('audioCapturerChange', function () { ...@@ -457,8 +433,6 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
let audioCap; let audioCap;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
...@@ -481,35 +455,20 @@ describe('audioCapturerChange', function () { ...@@ -481,35 +455,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 0 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 0 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + '[CAPTURER-CHANGE-ON-005] ResultFlag for element ' + i + ' is: ' + resultFlag); expect(true).assertTrue();
done();
} }
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audioCap.release();
audioCap = data; } catch (err) {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.log('err :' + JSON.stringify(err));
}).catch((err) => { expect(false).assertTrue();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); done();
}); }
await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-005] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -620,8 +579,6 @@ describe('audioCapturerChange', function () { ...@@ -620,8 +579,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
...@@ -642,34 +599,20 @@ describe('audioCapturerChange', function () { ...@@ -642,34 +599,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].streamId != undefined && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].streamId != undefined && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + '[CAPTURER-CHANGE-ON-007] ResultFlag for element ' + i + ' is: ' + resultFlag); expect(true).assertTrue();
done();
} }
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audioCap.release();
audioCap = data; } catch (err) {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.log('err :' + JSON.stringify(err));
}).catch((err) => { expect(false).assertTrue();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); done();
}); }
await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-007] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
...@@ -699,8 +642,6 @@ describe('audioCapturerChange', function () { ...@@ -699,8 +642,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
...@@ -723,34 +664,20 @@ describe('audioCapturerChange', function () { ...@@ -723,34 +664,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (clientUid != undefined && capFlags == 0 && devDescriptor != null) { if (clientUid != undefined && capFlags == 0 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + '[CAPTURER-CHANGE-ON-008] ResultFlag for element ' + i + ' is: ' + resultFlag); expect(true).assertTrue();
done();
} }
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audioCap.release();
audioCap = data; } catch (err) {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.log('err :' + JSON.stringify(err));
}).catch((err) => { expect(false).assertTrue();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); done();
}); }
await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-008] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -779,8 +706,6 @@ describe('audioCapturerChange', function () { ...@@ -779,8 +706,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
...@@ -805,34 +730,21 @@ describe('audioCapturerChange', function () { ...@@ -805,34 +730,21 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CC:' + i + ':' + cCount); console.info(Tag + 'CC:' + i + ':' + cCount);
console.info(Tag + 'CM:' + i + ':' + cMask); console.info(Tag + 'CM:' + i + ':' + cMask);
if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
} }
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audioCap.release();
audioCap = data; } catch (err) {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.log('err :' + JSON.stringify(err));
}).catch((err) => { expect(false).assertTrue();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); done();
}); }
await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-ON-009] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
...@@ -863,8 +775,6 @@ describe('audioCapturerChange', function () { ...@@ -863,8 +775,6 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = true;
let audioCap; let audioCap;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
...@@ -885,32 +795,20 @@ describe('audioCapturerChange', function () { ...@@ -885,32 +795,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
resultFlag = false; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
}); });
await sleep(100); try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
audioStreamManager.off('audioCapturerChange'); await audioCap.release();
await sleep(100); } catch (err) {
console.info(Tag + '[CAPTURER-CHANGE-OFF-001] ######### CapturerChange Off is called #########'); console.log('err :' + JSON.stringify(err));
console.info(Tag + '[CAPTURER-CHANGE-OFF-001] ResultFlag is: ' + resultFlag); expect(false).assertTrue();
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { done();
audioCap = data; }
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message);
});
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -940,17 +838,15 @@ describe('audioCapturerChange', function () { ...@@ -940,17 +838,15 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = true;
let audioCap; let audioCap;
try {
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
audioCap = data; await audioCap.start();
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); } catch (err) {
}).catch((err) => { console.log('err :' + JSON.stringify(err));
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); expect(false).assertTrue();
}); done();
}
await sleep(100);
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
...@@ -970,31 +866,17 @@ describe('audioCapturerChange', function () { ...@@ -970,31 +866,17 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
resultFlag = false; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
}); });
await sleep(100); await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-OFF-002] ######### CapturerChange Off is called #########');
console.info(Tag + '[CAPTURER-CHANGE-OFF-002] ResultFlag is: ' + resultFlag);
await audioCap.start().then(async function () {
console.info(Tag + 'Capturer started :SUCCESS ');
}).catch((err) => {
console.info(Tag + 'Capturer start :ERROR : ' + err.message);
});
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1024,23 +906,17 @@ describe('audioCapturerChange', function () { ...@@ -1024,23 +906,17 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = true;
let audioCap; let audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { try {
audioCap = data; audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); await audioCap.start();
}).catch((err) => { await audioCap.stop();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); } catch (err) {
}); console.log('err :' + JSON.stringify(err));
expect(false).assertTrue();
await audioCap.start().then(async function () { done();
console.info(Tag + 'Capturer started :SUCCESS '); }
}).catch((err) => {
console.info(Tag + 'Capturer start :ERROR : ' + err.message);
});
await sleep(100);
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
...@@ -1060,32 +936,18 @@ describe('audioCapturerChange', function () { ...@@ -1060,32 +936,18 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
resultFlag = false; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
}); });
await sleep(100); await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[CAPTURER-CHANGE-OFF-003] ######### CapturerChange Off is called #########');
console.info(Tag + '[CAPTURER-CHANGE-OFF-003] ResultFlag is: ' + resultFlag);
await audioCap.stop().then(async function () {
console.info(Tag + 'Capturer stopped : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer stop:ERROR : ' + err.message);
});
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1115,29 +977,17 @@ describe('audioCapturerChange', function () { ...@@ -1115,29 +977,17 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = true;
let audioCap; let audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { try {
audioCap = data; audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); await audioCap.start();
}).catch((err) => { await audioCap.stop();
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); } catch (err) {
}); console.log('err :' + JSON.stringify(err));
expect(false).assertTrue();
await audioCap.start().then(async function () { done();
console.info(Tag + 'Capturer started :SUCCESS '); }
}).catch((err) => {
console.info(Tag + 'Capturer start :ERROR : ' + err.message);
});
await audioCap.stop().then(async function () {
console.info(Tag + 'Capturer stopped : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer stop:ERROR : ' + err.message);
});
await sleep(100);
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
...@@ -1157,25 +1007,18 @@ describe('audioCapturerChange', function () { ...@@ -1157,25 +1007,18 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]);
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
resultFlag = false; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
}); });
await sleep(100); await sleep(100);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info('AFCapturerChangeLog: [CAP-CH-OFF-004] ## CapCh Off is called ##');
console.info(Tag + '[CAPTURER-CHANGE-OFF-004] ResultFlag is: ' + resultFlag);
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1204,9 +1047,6 @@ describe('audioCapturerChange', function () { ...@@ -1204,9 +1047,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = true;
let audioCap; let audioCap;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
...@@ -1233,34 +1073,21 @@ describe('audioCapturerChange', function () { ...@@ -1233,34 +1073,21 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CC:' + i + ':' + cCount); console.info(Tag + 'CC:' + i + ':' + cCount);
console.info(Tag + 'CM:' + i + ':' + cMask); console.info(Tag + 'CM:' + i + ':' + cMask);
if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) {
resultFlag = false; audioStreamManager.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
} }
} }
}); });
try {
await sleep(100); audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
await audioCap.release();
audioStreamManager.off('audioCapturerChange'); } catch (err) {
await sleep(100); console.log('err :' + JSON.stringify(err));
console.info(Tag + '[CAPTURER-CHANGE-OFF-005] ######### CapturerChange Off is called #########'); expect(false).assertTrue();
console.info(Tag + '[CAPTURER-CHANGE-OFF-005] ResultFlag is: ' + resultFlag); done();
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { }
audioCap = data;
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message);
});
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1289,8 +1116,6 @@ describe('audioCapturerChange', function () { ...@@ -1289,8 +1116,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
...@@ -1318,6 +1143,8 @@ describe('audioCapturerChange', function () { ...@@ -1318,6 +1143,8 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
await sleep(100); await sleep(100);
...@@ -1343,28 +1170,26 @@ describe('audioCapturerChange', function () { ...@@ -1343,28 +1170,26 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true; audioStreamManagerCB.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); console.info('audioCapturerChange off success ');
expect(true).assertTrue();
done();
} }
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(Tag + 'getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); console.info('err : ' + JSON.stringify(err));
resultFlag = false; expect(false).assertTrue();
done();
}); });
audioStreamManagerCB.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_1_PR] ## CapCh Off is called ##');
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1393,9 +1218,6 @@ describe('audioCapturerChange', function () { ...@@ -1393,9 +1218,6 @@ describe('audioCapturerChange', function () {
streamInfo: AudioStreamInfo, streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
let audioCap; let audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) {
...@@ -1433,6 +1255,8 @@ describe('audioCapturerChange', function () { ...@@ -1433,6 +1255,8 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'Capturer started :SUCCESS '); console.info(Tag + 'Capturer started :SUCCESS ');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer start :ERROR : ' + err.message); console.info(Tag + 'Capturer start :ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
await sleep(100); await sleep(100);
...@@ -1458,29 +1282,25 @@ describe('audioCapturerChange', function () { ...@@ -1458,29 +1282,25 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); expect(true).assertTrue();
done();
} }
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(Tag + 'getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); console.info('err : ' + JSON.stringify(err));
resultFlag = false; expect(false).assertTrue();
done();
}); });
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_2_PROMISE] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1510,8 +1330,6 @@ describe('audioCapturerChange', function () { ...@@ -1510,8 +1330,6 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
let audioCap; let audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) {
...@@ -1581,29 +1399,25 @@ describe('audioCapturerChange', function () { ...@@ -1581,29 +1399,25 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 3 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 3 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); expect(true).assertTrue();
done();
} }
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(Tag + 'getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); console.info('err : ' + JSON.stringify(err));
resultFlag = false; expect(false).assertTrue();
done();
}); });
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_3_PROMISE] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message); console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1690,7 +1504,9 @@ describe('audioCapturerChange', function () { ...@@ -1690,7 +1504,9 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CC:' + i + ':' + cCount); console.info(Tag + 'CC:' + i + ':' + cCount);
console.info(Tag + 'CM:' + i + ':' + cMask); console.info(Tag + 'CM:' + i + ':' + cMask);
if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) {
resultFlag = true; audioStreamManagerCB.off('audioCapturerChange');
expect(true).assertTrue();
done();
} }
} }
} }
...@@ -1700,10 +1516,6 @@ describe('audioCapturerChange', function () { ...@@ -1700,10 +1516,6 @@ describe('audioCapturerChange', function () {
resultFlag = false; resultFlag = false;
}); });
audioStreamManagerCB.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_DD_PR] ## CapCh Off is called ##');
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS'); console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => { }).catch((err) => {
...@@ -1800,28 +1612,20 @@ describe('audioCapturerChange', function () { ...@@ -1800,28 +1612,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
done();
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
});
} }
} }
} }
} }
}); });
await sleep(1000);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_1_CALLBACK] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -1921,29 +1725,20 @@ describe('audioCapturerChange', function () { ...@@ -1921,29 +1725,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 2 && devDescriptor != null) {
resultFlag = true; audioStreamManagerCB.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
done();
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
});
} }
} }
} }
} }
}); });
await sleep(1000);
audioStreamManagerCB.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_2_CALLBACK] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -2050,29 +1845,20 @@ describe('audioCapturerChange', function () { ...@@ -2050,29 +1845,20 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks);
} }
if (AudioCapturerChangeInfoArray[i].capturerState == 3 && devDescriptor != null) { if (AudioCapturerChangeInfoArray[i].capturerState == 3 && devDescriptor != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
console.info(Tag + 'State : ' + AudioCapturerChangeInfoArray[i].capturerState); await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
done();
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
});
} }
} }
} }
} }
}); });
await sleep(1000);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_STATE_3_CALLBACK] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
/** /**
...@@ -2102,7 +1888,6 @@ describe('audioCapturerChange', function () { ...@@ -2102,7 +1888,6 @@ describe('audioCapturerChange', function () {
capturerInfo: AudioCapturerInfo capturerInfo: AudioCapturerInfo
} }
let resultFlag = false;
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##');
...@@ -2130,6 +1915,8 @@ describe('audioCapturerChange', function () { ...@@ -2130,6 +1915,8 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS'); console.info(Tag + 'AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message); console.info(Tag + 'AudioCapturer Created : ERROR : ' + err.message);
expect(false).assertTrue();
done();
}); });
await sleep(100); await sleep(100);
...@@ -2165,28 +1952,21 @@ describe('audioCapturerChange', function () { ...@@ -2165,28 +1952,21 @@ describe('audioCapturerChange', function () {
console.info(Tag + 'CC:' + i + ':' + cCount); console.info(Tag + 'CC:' + i + ':' + cCount);
console.info(Tag + 'CM:' + i + ':' + cMask); console.info(Tag + 'CM:' + i + ':' + cMask);
if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) {
resultFlag = true; audioStreamManager.off('audioCapturerChange');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
done();
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
expect(false).assertTrue();
done();
});
} }
} }
} }
} }
} }
}); });
await sleep(1000);
audioStreamManager.off('audioCapturerChange');
await sleep(100);
console.info(Tag + '[GET_CAPTURER_DD_CALLBACK] ######### CapturerChange Off is called #########');
await audioCap.release().then(async function () {
console.info(Tag + 'Capturer release : SUCCESS');
}).catch((err) => {
console.info(Tag + 'Capturer release :ERROR : ' + err.message);
});
expect(resultFlag).assertTrue();
done();
}) })
}) })
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media" "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry"
], ],
"cleanup-apps": true "cleanup-apps": true
}, },
...@@ -38,12 +39,7 @@ ...@@ -38,12 +39,7 @@
"./resource/audio/audioManager/StarWars10s-2C-16000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/", "./resource/audio/audioManager/StarWars10s-2C-16000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-22050-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/", "./resource/audio/audioManager/StarWars10s-2C-22050-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-24000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/", "./resource/audio/audioManager/StarWars10s-2C-24000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-48000-4SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/", "./resource/audio/audioManager/StarWars10s-2C-48000-4SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/"
"./resource/audio/audioManager/Believer.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media",
"./resource/audio/audioManager/file_example_WAV_1MG.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media",
"./resource/audio/audioManager/safe_and_sound_32.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media",
"./resource/audio/audioManager/test.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media",
"./resource/audio/audioManager/test.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiorenderer/haps/entry/files/media"
] ]
} }
] ]
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiovoip/haps/entry/files/media" "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiovoip/haps/entry/files",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiovoip/haps/entry"
], ],
"cleanup-apps": true "cleanup-apps": true
}, },
......
...@@ -27,208 +27,215 @@ describe('audioVoip', function () { ...@@ -27,208 +27,215 @@ describe('audioVoip', function () {
let readpath; let readpath;
let fdPath; let fdPath;
let filePath; let filePath;
let TagRender = "AudioFrameworkRenderLog";
let TagRec = "AudioFrameworkRecLog";
const AUDIOMANAGER = audio.getAudioManager(); const AUDIOMANAGER = audio.getAudioManager();
console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework'); console.info(`${TagRender}: Create AudioManger Object JS Framework`);
beforeAll(async function () { beforeAll(async function () {
console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level'); console.info(`AudioFrameworkTest: beforeAll: Prerequisites at the test suite level`);
let permissionName1 = 'ohos.permission.MICROPHONE'; let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionNameList = [permissionName1]; let permissionNameList = [permissionName1];
let appName = 'ohos.acts.multimedia.audio.audiovoip'; let appName = 'ohos.acts.multimedia.audio.audiovoip';
await audioTestBase.applyPermission(appName, permissionNameList); await audioTestBase.applyPermission(appName, permissionNameList);
await sleep(100); await sleep(100);
console.info('AudioFrameworkTest: beforeAll: END'); console.info(`AudioFrameworkTest: beforeAll: END`);
}) })
beforeEach(async function () { beforeEach(async function () {
console.info('AudioFrameworkTest: beforeEach: Prerequisites at the test case level'); console.info(`AudioFrameworkTest: beforeEach: Prerequisites at the test case level`);
await sleep(1000); await sleep(1000);
}) })
afterEach(function () { afterEach(function () {
console.info('AudioFrameworkTest: afterEach: Test case-level clearance conditions'); console.info(`AudioFrameworkTest: afterEach: Test case-level clearance conditions`);
}) })
afterAll(async function () { afterAll(async function () {
console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition'); console.info(`AudioFrameworkTest: afterAll: Test suite-level cleanup condition`);
}) })
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
} }
async function getAbilityInfo(fileName) { async function getAbilityInfo(fileName) {
let context = await featureAbility.getContext(); let context = await featureAbility.getContext();
console.info("case0 context is " + context); console.info(`case0 context is " ${context}`);
await context.getFilesDir().then((data) => { await context.getFilesDir().then((data) => {
console.info("case1 getFilesDir is path " + data); console.info(`case1 getFilesDir path is : ${data}`);
mediaDir = data + '/' + fileName; mediaDir = data + '/' + fileName;
console.info('case2 mediaDir is ' + mediaDir); console.info(`case2 mediaDir is : ${mediaDir}`);
}) }).catch(error => {
console.log(`${TagRender}:case getFileDir err: ${error}`);
});
} }
async function closeFileDescriptor(fileName) { async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => { await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.closeRawFileDescriptor(fileName).then(value => { await mgr.closeRawFileDescriptor(fileName).then(value => {
console.log('AudioFrameworkRenderLog:case closeRawFileDescriptor success for file:' + fileName); console.log(`${TagRender}:case closeRawFileDescriptor success for file: ${fileName}`);
}).catch(error => { }).catch(err => {
console.log('AudioFrameworkRenderLog:case closeRawFileDescriptor err: ' + error); console.log(`${TagRender}:case closeRawFileDescriptor err: ${err}`);
}); });
}).catch(error => {
console.log(`${TagRender}:case getResourceManager err: ${error}`);
}); });
} }
async function getFdRead(pathName) { async function getFdRead(pathName) {
let context = await featureAbility.getContext(); let context = await featureAbility.getContext();
console.info("case0 context is " + context); console.info(`case0 context is ${context}`);
await context.getFilesDir().then((data) => { await context.getFilesDir().then((data) => {
console.info("case1 getFilesDir is path " + data); console.info(`case1 getFilesDir path is : ${data}`);
filePath = data + '/' + pathName; filePath = data + '/' + pathName;
console.info('case4 filePath is ' + filePath); console.info(`case4 filePath is : ${filePath}`);
}).catch(err => {
}) console.log(`${TagRender}:case getFilesDir err: ${err}`);
});
fdPath = 'fd://'; fdPath = 'fd://';
await fileio.open(filePath).then((fdNumber) => { await fileio.open(filePath).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
fdRead = fdNumber; fdRead = fdNumber;
console.info('[fileIO]case open fd success,fdPath is ' + fdPath); console.info(`[fileIO]case open fd success,fdPath is : ${fdPath}`);
console.info('[fileIO]case open fd success,fdRead is ' + fdRead); console.info(`[fileIO]case open fd success,fdRead is : ${fdRead}`);
}, (err) => { }, (err) => {
console.info('[fileIO]case open fd failed'); console.info(`[fileIO]case open fd err : ${err}`);
}).catch((err) => { }).catch((error) => {
console.info('[fileIO]case catch open fd failed'); console.info(`[fileIO]case catch open fd failed : ${error}`);
}); });
} }
async function playbackPromise(AudioRendererOptions, pathName) { async function playbackPromise(AudioRendererOptions, pathName) {
let resultFlag = 'new'; let resultFlag = 'new';
console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function'); console.info(`${TagRender}: Promise : Audio Playback Function`);
let audioRen; let audioRen;
await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) {
audioRen = data; audioRen = data;
console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS'); console.info(`${TagRender}: AudioRender Created : Success : Stream Type: SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); console.info(`${TagRender}: AudioRender Created : ERROR : ${err.message}`);
return resultFlag; return resultFlag;
}); });
console.info('AudioFrameworkRenderLog: AudioRenderer : Path : ' + pathName); console.info(`${TagRender}: AudioRenderer : Path : ${pathName}`);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state); console.info(`${TagRender}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.getStreamInfo().then(async function (audioParamsGet) { await audioRen.getStreamInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer getStreamInfo:'); console.info(`${TagRender}: Renderer getStreamInfo:`);
console.info('AudioFrameworkRenderLog: Renderer sampleFormat:' + audioParamsGet.sampleFormat); console.info(`${TagRender}: Renderer sampleFormat: ${audioParamsGet.sampleFormat}`);
console.info('AudioFrameworkRenderLog: Renderer samplingRate:' + audioParamsGet.samplingRate); console.info(`${TagRender}: Renderer samplingRate: ${audioParamsGet.samplingRate}`);
console.info('AudioFrameworkRenderLog: Renderer channels:' + audioParamsGet.channels); console.info(`${TagRender}: Renderer channels: ${audioParamsGet.channels}`);
console.info('AudioFrameworkRenderLog: Renderer encodingType:' + audioParamsGet.encodingType); console.info(`${TagRender}: Renderer encodingType: ${audioParamsGet.encodingType}`);
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: ' + err.message); console.log(`${TagRender}: getStreamInfo :ERROR: ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
await audioRen.getRendererInfo().then(async function (audioParamsGet) { await audioRen.getRendererInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer RendererInfo:'); console.info(`${TagRender}: Renderer RendererInfo:`);
console.info('AudioFrameworkRenderLog: Renderer content type:' + audioParamsGet.content); console.info(`${TagRender}: Renderer content type: ${audioParamsGet.content}`);
console.info('AudioFrameworkRenderLog: Renderer usage:' + audioParamsGet.usage); console.info(`${TagRender}: Renderer usage: ${audioParamsGet.usage}`);
console.info('AudioFrameworkRenderLog: Renderer rendererFlags:' + audioParamsGet.rendererFlags); console.info(`${TagRender}: Renderer rendererFlags: ${audioParamsGet.rendererFlags}`);
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: ' + err.message); console.log(`${TagRender}: RendererInfo :ERROR: ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
await audioRen.start().then(async function () { await audioRen.start().then(async function () {
console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); console.info(`${TagRender}: renderInstant started :SUCCESS `);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); console.info(`${TagRender}: renderInstant start :ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state); console.info(`${TagRender}: AudioRenderer : STATE : ${audioRen.state}`);
let bufferSize; let bufferSize;
await audioRen.getBufferSize().then(async function (data) { await audioRen.getBufferSize().then(async function (data) {
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS ' + data); console.info(`${TagRender}: getBufferSize :SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : ' + err.message); console.info(`${TagRender}: getBufferSize :ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
let ss = fileio.fdopenStreamSync(fdRead, 'r'); let ss = fileio.fdopenStreamSync(fdRead, 'r');
console.info('AudioFrameworkRenderLog:case2: File Path: ' + ss); console.info(`${TagRender}: case2: File Path: ${ss}`);
let discardHeader = new ArrayBuffer(44); let discardHeader = new ArrayBuffer(44);
ss.readSync(discardHeader); ss.readSync(discardHeader);
let totalSize = fileio.fstatSync(fdRead).size; let totalSize = fileio.fstatSync(fdRead).size;
console.info('AudioFrameworkRenderLog:case3: File totalSize size: ' + totalSize); console.info(`${TagRender}: case3: File totalSize size: ${totalSize}`);
totalSize = totalSize - 44; totalSize = totalSize - 44;
console.info('AudioFrameworkRenderLog: File size : Removing header: ' + totalSize); console.info(`${TagRender}: File size : Removing header: ${totalSize}`);
let rlen = 0; let rlen = 0;
while (rlen < totalSize / 4) { while (rlen < totalSize / 4) {
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
rlen += ss.readSync(buf); rlen += ss.readSync(buf);
console.info('AudioFrameworkRenderLog:BufferAudioFramework: bytes read from file: ' + rlen); console.info(`${TagRender}: BufferAudioFramework: bytes read from file: ${rlen}`);
await audioRen.write(buf); await audioRen.write(buf);
if (rlen > (totalSize / 2)) { if (rlen > (totalSize / 2)) {
await AUDIOMANAGER.getAudioScene().then(async function (data) { await AUDIOMANAGER.getAudioScene().then(async function (data) {
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : Value : ' + data); console.info(`${TagRender}:AudioFrameworkAudioScene: getAudioScene : Value : ${data}`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : ERROR : ' + err.message); console.info(`${TagRender}:AudioFrameworkAudioScene: getAudioScene : ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
} }
} }
console.info('AudioFrameworkRenderLog: Renderer after read'); console.info(`${TagRender}: Renderer after read`);
await audioRen.drain().then(async function () { await audioRen.drain().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); console.info(`${TagRender}: Renderer drained : SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : ' + err.message); console.error(`${TagRender}: Renderer drain: ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state); console.info(`${TagRender}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.stop().then(async function () { await audioRen.stop().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); console.info(`${TagRender}: Renderer stopped : SUCCESS`);
resultFlag = true; resultFlag = true;
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlag); console.info(`${TagRender}: resultFlagRen : ${resultFlag}`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : ' + err.message); console.info(`${TagRender}: Renderer stop:ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state); console.info(`${TagRender}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.release().then(async function () { await audioRen.release().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); console.info(`${TagRender}: Renderer release : SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : ' + err.message); console.info(`${TagRender}: Renderer release :ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state); console.info(`${TagRender}: AudioRenderer : STATE : ${audioRen.state}`);
console.info(`${TagRender}: resultFlag : ${resultFlag}`);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag);
return resultFlag; return resultFlag;
} }
...@@ -236,131 +243,131 @@ describe('audioVoip', function () { ...@@ -236,131 +243,131 @@ describe('audioVoip', function () {
async function recPromise(AudioCapturerOptions, fpath) { async function recPromise(AudioCapturerOptions, fpath) {
let resultFlag = 'new'; let resultFlag = 'new';
console.info('AudioFrameworkRecLog: Promise : Audio Recording Function'); console.info(`${TagRec}: Promise : Audio Recording Function`);
let audioCap; let audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) {
audioCap = data; audioCap = data;
console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); console.info(`${TagRec}: AudioCapturer Created : Success : Stream Type: SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message); console.info(`${TagRec}: AudioCapturer Created : ERROR : ${err.message}`);
return resultFlag; return resultFlag;
}); });
console.info('AudioFrameworkRecLog: AudioCapturer : Path : ' + fpath); console.info(`${TagRec}: AudioCapturer : Path : ${fpath}`);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state); console.info(`${TagRec}: AudioCapturer : STATE : ${audioCap.state}`);
await audioCap.getStreamInfo().then(async function (audioParamsGet) { await audioCap.getStreamInfo().then(async function (audioParamsGet) {
if (audioParamsGet != undefined) { if (audioParamsGet != undefined) {
console.info('AudioFrameworkRecLog: Capturer getStreamInfo:'); console.info(`${TagRec}: Capturer getStreamInfo:`);
console.info('AudioFrameworkRecLog: Capturer sampleFormat:' + audioParamsGet.sampleFormat); console.info(`${TagRec}: Capturer sampleFormat: ${audioParamsGet.sampleFormat}`);
console.info('AudioFrameworkRecLog: Capturer samplingRate:' + audioParamsGet.samplingRate); console.info(`${TagRec}: Capturer samplingRate: ${audioParamsGet.samplingRate}`);
console.info('AudioFrameworkRecLog: Capturer channels:' + audioParamsGet.channels); console.info(`${TagRec}: Capturer channels: ${audioParamsGet.channels}`);
console.info('AudioFrameworkRecLog: Capturer encodingType:' + audioParamsGet.encodingType); console.info(`${TagRec}: Capturer encodingType: ${audioParamsGet.encodingType}`);
} else { } else {
console.info('AudioFrameworkRecLog: audioParamsGet is : ' + audioParamsGet); console.info(`${TagRec}: audioParamsGet is : ${audioParamsGet}`);
console.info('AudioFrameworkRecLog: audioParams getStreamInfo are incorrect: '); console.info(`${TagRec}: audioParams getStreamInfo are incorrect: `);
resultFlag = false; resultFlag = false;
} }
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: ' + err.message); console.log(`${TagRec}: getStreamInfo :ERROR: ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRecLog: resultFlag : ' + resultFlag); console.info(`${TagRec}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
await audioCap.getCapturerInfo().then(async function (audioParamsGet) { await audioCap.getCapturerInfo().then(async function (audioParamsGet) {
if (audioParamsGet != undefined) { if (audioParamsGet != undefined) {
console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); console.info(`${TagRec}: Capturer CapturerInfo:`);
console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); console.info(`${TagRec}: Capturer SourceType: ${audioParamsGet.source}`);
console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); console.info(`${TagRec}: Capturer capturerFlags: ${audioParamsGet.capturerFlags}`);
} else { } else {
console.info('AudioFrameworkRecLog: audioParamsGet is : ' + audioParamsGet); console.info(`${TagRec}: audioParamsGet is : ${audioParamsGet}`);
console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: '); console.info(`${TagRec}: audioParams getCapturerInfo are incorrect: `);
resultFlag = false; resultFlag = false;
} }
}).catch((err) => { }).catch((err) => {
console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: ' + err.message); console.log(`${TagRec}: CapturerInfo :ERROR: ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRecLog: resultFlag : ' + resultFlag); console.info(`${TagRec}: resultFlag : ${esultFlag}`);
return resultFlag; return resultFlag;
} }
await audioCap.start().then(async function () { await audioCap.start().then(async function () {
console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); console.info(`${TagRec}: Capturer started :SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : ' + err.message); console.info(`${TagRec}: Capturer start :ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
if (resultFlag == false) { if (resultFlag == false) {
console.info('AudioFrameworkRecLog: resultFlag : ' + resultFlag); console.info(`${TagRec}: resultFlag : ${resultFlag}`);
return resultFlag; return resultFlag;
} }
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state); console.info(`${TagRec}: AudioCapturer : STATE : ${audioCap.state}`);
let bufferSize = await audioCap.getBufferSize(); let bufferSize = await audioCap.getBufferSize();
console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); console.info(`${TagRec}: buffer size: ${bufferSize}`);
let fd = fileio.openSync(fpath, 0o102, 0o777); let fd = fileio.openSync(fpath, 0o102, 0o777);
if (fd !== null) { if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd created'); console.info(`${TagRec}: file fd created`);
} }
else { else {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); console.info(`${TagRec}: Capturer start :ERROR : `);
resultFlag = false; resultFlag = false;
return resultFlag; return resultFlag;
} }
fd = fileio.openSync(fpath, 0o2002, 0o666); fd = fileio.openSync(fpath, 0o2002, 0o666);
if (fd !== null) { if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd opened : Append Mode :PASS'); console.info(`${TagRec}: file fd opened : Append Mode :PASS`);
} }
else { else {
console.info('AudioFrameworkRecLog: file fd Open: Append Mode : FAILED'); console.info(`${TagRec}: file fd Open: Append Mode : FAILED`);
resultFlag = false; resultFlag = false;
return resultFlag; return resultFlag;
} }
await sleep(100); await sleep(100);
let numBuffersToCapture = 45; let numBuffersToCapture = 45;
while (numBuffersToCapture) { while (numBuffersToCapture) {
console.info('AudioFrameworkRecLog: ---------READ BUFFER---------'); console.info(`${TagRec}: ---------READ BUFFER---------`);
let buffer = await audioCap.read(bufferSize, true); let buffer = await audioCap.read(bufferSize, true);
await sleep(50); await sleep(50);
console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); console.info(`${TagRec}: ---------WRITE BUFFER---------`);
let number = fileio.writeSync(fd, buffer); let number = fileio.writeSync(fd, buffer);
console.info('AudioFrameworkRecLog:BufferRecLog: data written: ' + number); console.info(`${TagRec}:BufferRecLog: data written: ${number}`);
await sleep(50); await sleep(50);
numBuffersToCapture--; numBuffersToCapture--;
} }
await sleep(1000); await sleep(1000);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state); console.info(`${TagRec}: AudioCapturer : STATE : ${audioCap.state}`);
await audioCap.stop().then(async function () { await audioCap.stop().then(async function () {
console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); console.info(`${TagRec}: Capturer stopped : SUCCESS`);
resultFlag = true; resultFlag = true;
console.info('AudioFrameworkRecLog: resultFlag : ' + resultFlag); console.info(`${TagRec}: resultFlag : ${resultFlag}`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop:ERROR : ' + err.message); console.info(`${TagRec}: Capturer stop:ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state); console.info(`${TagRec}: AudioCapturer : STATE : ${audioCap.state}`);
await audioCap.release().then(async function () { await audioCap.release().then(async function () {
console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); console.info(`${TagRec}: Capturer release : SUCCESS`);
}).catch((err) => { }).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); console.info(`${TagRec}: Capturer release :ERROR : ${err.message}`);
resultFlag = false; resultFlag = false;
}); });
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state); console.info(`${TagRec}: AudioCapturer : STATE : ${audioCap.state}`);
return resultFlag; return resultFlag;
...@@ -397,7 +404,7 @@ describe('audioVoip', function () { ...@@ -397,7 +404,7 @@ describe('audioVoip', function () {
await getFdRead("StarWars10s-1C-44100-2SW.wav"); await getFdRead("StarWars10s-1C-44100-2SW.wav");
let resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); let resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100); await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
expect(resultFlag).assertTrue(); expect(resultFlag).assertTrue();
await closeFileDescriptor(filePath); await closeFileDescriptor(filePath);
done(); done();
...@@ -433,7 +440,7 @@ describe('audioVoip', function () { ...@@ -433,7 +440,7 @@ describe('audioVoip', function () {
await getAbilityInfo("capture_js-44100-2C-16B.pcm"); await getAbilityInfo("capture_js-44100-2C-16B.pcm");
let resultFlag = await recPromise(AudioCapturerOptions, mediaDir); let resultFlag = await recPromise(AudioCapturerOptions, mediaDir);
await sleep(100); await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
expect(resultFlag).assertTrue(); expect(resultFlag).assertTrue();
done(); done();
}) })
...@@ -491,7 +498,7 @@ describe('audioVoip', function () { ...@@ -491,7 +498,7 @@ describe('audioVoip', function () {
await getFdRead(readpath); await getFdRead(readpath);
let resultFlag = await playbackPromise(AudioRendererOptions, readpath); let resultFlag = await playbackPromise(AudioRendererOptions, readpath);
await sleep(100); await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); console.info(`${TagRender}: resultFlag : ${resultFlag}`);
expect(resultFlag).assertTrue(); expect(resultFlag).assertTrue();
await closeFileDescriptor(readpath); await closeFileDescriptor(readpath);
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册