Jessibuca是一款开源的纯H5直播流播放器,通过Emscripten将音视频解码库编译成Js(ams.js/wasm)运行于浏览器之中。兼容几乎所有浏览器,可以运行在PC、手机、微信中,无需额外安装插件。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
878 B

#pragma once
#include <speex/speex.h>
class SpeexDecoder : public AudioDecoder {
i16 *audioOutput;
void *speexState;
SpeexBits speexBits;
public:
SpeexDecoder():AudioDecoder(){
audioOutput = (i16 *)malloc(640);
auto mode = speex_lib_get_mode(SPEEX_MODEID_WB);
speexState = speex_decoder_init(mode);
speex_bits_init(&speexBits);
emscripten_log(0, "speex init!");
}
virtual ~SpeexDecoder(){
speex_decoder_destroy(speexState);
speex_bits_destroy(&speexBits);
free(audioOutput);
}
int _decode(IOBuffer &input) override
{
u8 *output = outputBuffer + bufferFilled;
if (input.length <= 11)
{
memset(output, 0, 640);
}
else
{
speex_bits_read_from(&speexBits, (const char *)input, 52);
speex_decode_int(speexState, &speexBits, audioOutput);
memcpy(output, audioOutput, 640);
}
return 640;
}
};