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.
 
 
 

45 lines
1.1 KiB

#pragma once
#include "libde265/de265.h"
#include "libde265/image.h"
class Libde265 : public VideoDecoder
{
public:
de265_PTS pts;
de265_decoder_context *h265DecContext;
Libde265()
{
h265DecContext = de265_new_decoder();
emscripten_log(0, "H265 init");
}
~Libde265()
{
de265_free_decoder(h265DecContext);
}
void _decode(IOBuffer data) override
{
de265_push_NAL(h265DecContext, (const unsigned char *)data, data.length, 0, nullptr);
int more = 1;
while (more)
{
more = 0;
auto err = de265_decode(h265DecContext, &more);
if (err != DE265_OK)
{
if (err != DE265_ERROR_WAITING_FOR_INPUT_DATA)
emscripten_log(0, "de265_decode:%d", err);
break;
}
const de265_image *img = de265_get_next_picture(h265DecContext);
if (img)
{
//emscripten_log(0, "%d", img);
int out_stride;
for (int i = 0; i < 3; i++)
p_yuv[i] = (u32)de265_get_image_plane(img, i, &out_stride);
if (videoWidth == 0)
decodeVideoSize(de265_get_image_width(img, 0), de265_get_image_height(img, 0));
decodeYUV420();
}
}
}
};