| | |
| | | fn_cpu(h); |
| | | } |
| | | |
| | | void wrap_fn_open_rec(void *lib, const cffmpeg h){ |
| | | if (!fn_open_recorder){ |
| | | fn_open_recorder = (lib_cffmpeg_open_recorder)dlsym(lib, "c_ffmpeg_open_recorder"); |
| | | if (!fn_open_recorder) return; |
| | | } |
| | | fn_open_recorder(h); |
| | | } |
| | | |
| | | void wrap_fn_recorder(void *lib, const cffmpeg h, const char* id, const char* dir, const int64_t fid, int mind, int maxd, int audio){ |
| | | if (!fn_recorder){ |
| | | fn_recorder = (lib_cffmpeg_recorder)dlsym(lib, "c_ffmpeg_build_recorder"); |
| | |
| | | return fn_decoder_pic(h, wid, hei, format, length, id); |
| | | } |
| | | |
| | | void wrap_fn_close_stream(void *lib, const cffmpeg h){ |
| | | if (!fn_close_stream){ |
| | | fn_close_stream = (lib_cffmpeg_close_stream)dlsym(lib, "c_ffmpeg_close_stream"); |
| | | if (!fn_close_stream) return; |
| | | } |
| | | fn_close_stream(h); |
| | | } |
| | | |
| | | void* wrap_fn_get_avpacket(void *lib, const cffmpeg h, int* size, int* key){ |
| | | if(!fn_get_avpacket){ |
| | | fn_get_avpacket = (lib_cffmpeg_avpacket)dlsym(lib, "c_ffmpeg_get_avpacket"); |
| | |
| | | return fn_get_avpacket(h, size, key); |
| | | } |
| | | |
| | | // return val: -1 open error; -2, find stream error; -3, converter create error |
| | | void* wrap_fn_decode(void *lib, const char* file, const int gb, int* wid, int* hei){ |
| | | if (!fn_decode){ |
| | | fn_decode = (lib_cffmpeg_decode)dlsym(lib, "c_ffmpeg_decode"); |
| | | release_if_err(fn_decode, lib); |
| | | } |
| | | return fn_decode(file, gb, wid, hei); |
| | | } |
| | | |
| | | // for encoder |
| | | cencoder wrap_fn_create_encoder(void *lib, const int w, const int h, const int fps, const int br, const int scale_flag, const int gi){ |
| | | cencoder wrap_fn_create_encoder(void *lib, const int w, const int h, const int fps, const int br, const int pix_fmt, const int scale_flag, const int gi){ |
| | | if (!fn_create_encoder){ |
| | | fn_create_encoder = (lib_cffmpeg_create_encoder)dlsym(lib, "c_ffmpeg_create_encoder"); |
| | | release_if_err(fn_create_encoder, lib); |
| | | } |
| | | return fn_create_encoder(w, h, fps, br, scale_flag, gi); |
| | | return fn_create_encoder(w, h, fps, br, pix_fmt, scale_flag, gi); |
| | | } |
| | | |
| | | void wrap_fn_destroy_encoder(void *lib, const cencoder h){ |
| | |
| | | |
| | | uint8_t *out = NULL; |
| | | const int flag = fn_encode(hdl, (uint8_t*)in, w, h, &out, out_size, key); |
| | | if (flag > 0 && out != NULL) { |
| | | if (flag == 0 && out != NULL) { |
| | | return out; |
| | | } |
| | | *out_size = 0; |
| | | *key = 0; |
| | | return NULL; |
| | | } |
| | | |
| | | // for conv |
| | | cconv wrap_fn_create_conv(void *lib, const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int dstFormat, const int flag){ |
| | | if (!fn_create_conv){ |
| | | fn_create_conv = (lib_cffmpeg_create_conv)dlsym(lib, "c_ffmpeg_create_conv"); |
| | | release_if_err(fn_create_conv, lib); |
| | | } |
| | | return fn_create_conv(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flag); |
| | | } |
| | | |
| | | void wrap_fn_destroy_conv(void *lib, const cconv h){ |
| | | if (!fn_destroy_conv){ |
| | | fn_destroy_conv = (lib_cffmpeg_destroy_conv)dlsym(lib, "c_ffmpeg_destroy_conv"); |
| | | if(!fn_destroy_conv) return; |
| | | } |
| | | fn_destroy_conv(h); |
| | | } |
| | | |
| | | void* wrap_fn_conv(void *lib, const cconv h, uint8_t *in){ |
| | | if (!fn_conv){ |
| | | fn_conv = (lib_cffmpeg_conv)dlsym(lib, "c_ffmpeg_conv"); |
| | | release_if_err(fn_conv, lib); |
| | | } |
| | | |
| | | return fn_conv(h, in); |
| | | } |