Add opus codec test

This commit is contained in:
dijunkun
2023-11-21 22:30:25 -08:00
parent 19506af831
commit e44c5b1cc7
12 changed files with 368 additions and 2 deletions

31
tests/opus/main.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <fstream>
#include <iostream>
#include <vector>
#include "OpusEncoderImpl.h"
#include "opus/opus.h"
int main() {
OpusEncoderImpl* opusEncoder = new OpusEncoderImpl(48000, 2);
std::ifstream inputFile("ls.pcm", std::ios::binary);
if (!inputFile) {
std::cerr << "Failed to open input file." << std::endl;
return -1;
}
char sample[960];
while (inputFile.read(sample, 960)) {
opusEncoder->Feed((unsigned char*)sample, 960);
}
// // 读取编码后的opus一般放在单独线程这里只是为了方便
// StreamInfo info;
// while (opusEncoder.PopFrame(info)) {
// .....
// }
opusEncoder->Stop();
return 0;
}