video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2021-05-25 48c8a8ce082ebdb992cb52cdd766298e8ca19011
bug fixed gb28181 capture picture
8个文件已修改
28 ■■■■■ 已修改文件
cffmpeg.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/cffmpeg.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/thirdparty/gb28181/include/PsToEs.hpp 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.hpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
goffmpeg.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcffmpeg.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcffmpeg.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cffmpeg.h
@@ -17,7 +17,7 @@
int c_ffmpeg_get_fps(const cffmpeg h);
void c_ffmpeg_run_gb28181(const cffmpeg h);
char * c_ffmpeg_get_gb28181_pic(const char *rtspUrl, int *retDataLen);
char * c_ffmpeg_get_gb28181_pic(const char *rtspUrl, int *retDataLen, const int tt);
void c_ffmepg_use_cpu(const cffmpeg h);
/////////passive api
void c_ffmpeg_open_recorder(const cffmpeg h);
csrc/cffmpeg.cpp
@@ -43,9 +43,9 @@
    s->GB28181();
}
char * c_ffmpeg_get_gb28181_pic(const char *rtspUrl, int *retDataLen){
char * c_ffmpeg_get_gb28181_pic(const char *rtspUrl, int *retDataLen, const int tt){
    char * retData = (char *)malloc(sizeof(char) * 3000000);
    int flag = GetGb28181Pic(rtspUrl, retData, retDataLen);
    int flag = GetGb28181Pic(rtspUrl, retData, retDataLen, tt);
    if(flag == -1){
        free(retData);
        *retDataLen = 0;
csrc/thirdparty/gb28181/include/PsToEs.hpp
@@ -177,13 +177,17 @@
        return bufsize;
    }
    static int capturePic(void *opaque, char *buf, int *bufsize) {
    static int capturePic(void *opaque, char *buf, int *bufsize, const int tt) {
        GB28181API *_this = (GB28181API *) opaque;
        int len = 0;
        *bufsize = 0;
        int ttt = 0;
        do {
            if (ttt > tt) return 0;
            ttt++;
            //从缓存中获取buffinfo
            if (_this->m_rtpQueue.count_queue() == 0) {
//                printf(" count_queue == 0 \n");
csrc/wrapper.cpp
@@ -453,7 +453,7 @@
        return flag;
    }
    int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen){
    int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen, const int tt){
        int ret = 0;
        std::string fn = rtspUrl;
@@ -464,7 +464,7 @@
            return -1;
        }
        int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen);
        int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen, tt);
        if(retLen == 0){
            logIt("do capturePic failed:%d");
            ret = -1;
csrc/wrapper.hpp
@@ -96,7 +96,7 @@
                        const int pix_fmt, const int scale_flag, const int gi);
    void DestroyEncoder(void *h);
    int Encode(void *hdl, uint8_t *in, const int w, const int h, uint8_t **out, int *size, int *key);
    int GetGb28181Pic(const char *filename, char *retData, int *retDataLen);
    int GetGb28181Pic(const char *filename, char *retData, int *retDataLen, const int tt);
}
#endif
goffmpeg.go
@@ -209,12 +209,12 @@
}
// GetGBJpg Get GB28181 Jpg
func GetGBJpg(rtspURL string) []byte {
func GetGBJpg(rtspURL string, maxTry int) []byte {
    rtsp := C.CString(rtspURL)
    defer C.free(unsafe.Pointer(rtsp))
    var jpgLen C.int
    pic := C.wrap_fn_get_gb28181_pic(unsafe.Pointer(libcffmpeg), rtsp, &jpgLen)
    pic := C.wrap_fn_get_gb28181_pic(unsafe.Pointer(libcffmpeg), rtsp, &jpgLen, C.int(maxTry))
    defer C.free(unsafe.Pointer(pic))
    retJpg := C.GoBytes(unsafe.Pointer(pic), jpgLen)
libcffmpeg.c
@@ -79,7 +79,7 @@
    fn_gb28181(h);
}
char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen){
char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen, const int tt){
    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) {
@@ -87,7 +87,7 @@
            return NULL;
        }
    }
    return fn_get_gb28181_pic(rtspUrl, retDataLen);
    return fn_get_gb28181_pic(rtspUrl, retDataLen, tt);
}
void wrap_fn_use_cpu(void *lib, const cffmpeg h){
libcffmpeg.h
@@ -62,7 +62,7 @@
void wrap_fn_run(void *lib, const cffmpeg h, const char* input);
int wrap_fn_fps(void *lib, const cffmpeg h);
void wrap_fn_run_gb28181(void *lib, const cffmpeg h);
char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen);
char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen, const int tt);
void wrap_fn_use_cpu(void *lib, const cffmpeg h);
void wrap_fn_open_rec(void *lib, const cffmpeg h);
void wrap_fn_rec_duration(void *lib, const cffmpeg h, const int min, const int max);