From d0b8204e3939e1e2d841a90ea254bc4b91309ab5 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期日, 19 一月 2020 13:32:13 +0800 Subject: [PATCH] update ffmepg gpu balance --- libcffmpeg.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libcffmpeg.c b/libcffmpeg.c index 6237dde..cbdc727 100644 --- a/libcffmpeg.c +++ b/libcffmpeg.c @@ -79,12 +79,31 @@ fn_gb28181(h); } +char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen){ + if (!fn_get_gb28181_pic){ + fn_get_gb28181_pic = (lib_cffmpeg_get_gb28181_pic)dlsym(lib, "c_ffmpeg_get_gb28181_pic"); + if(!fn_get_gb28181_pic) { + *retDataLen = 0; + return NULL; + } + } + return fn_get_gb28181_pic(rtspUrl, retDataLen); +} + void wrap_fn_use_cpu(void *lib, const cffmpeg h){ if (!fn_cpu){ fn_cpu = (lib_cffmpeg_cpu)dlsym(lib, "c_ffmepg_use_cpu"); if (!fn_cpu) return; } 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){ @@ -135,6 +154,14 @@ 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"); @@ -144,12 +171,12 @@ } // 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){ -- Gitblit v1.8.0