| | |
| | | |
| | | 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, const int tt); |
| | | int c_ffmpeg_get_gb28181_pic(const char *rtspUrl, char** ret, int *retDataLen, const int tt); |
| | | void c_ffmepg_use_cpu(const cffmpeg h); |
| | | /////////passive api |
| | | void c_ffmpeg_open_recorder(const cffmpeg h); |
| | |
| | | s->GB28181(); |
| | | } |
| | | |
| | | char * c_ffmpeg_get_gb28181_pic(const char *rtspUrl, int *retDataLen, const int tt){ |
| | | int c_ffmpeg_get_gb28181_pic(const char *rtspUrl, char** ret, int *retDataLen, const int tt){ |
| | | char * retData = (char *)malloc(sizeof(char) * 3000000); |
| | | int flag = GetGb28181Pic(rtspUrl, retData, retDataLen, tt); |
| | | if(flag == -1){ |
| | | if(flag <= 0){ |
| | | free(retData); |
| | | *retDataLen = 0; |
| | | return NULL; |
| | | *ret = NULL; |
| | | } |
| | | *ret = retData; |
| | | |
| | | return retData; |
| | | return flag; |
| | | } |
| | | |
| | | void c_ffmepg_use_cpu(const cffmpeg h){ |
| | |
| | | std::string ru(rtspUrl); |
| | | if(handle_gb28181->addCamera(ru) == -1){ |
| | | delete(handle_gb28181); |
| | | logIt("do addCamera Error\n"); |
| | | printf("do addCamera Error\n"); |
| | | ret = -2; |
| | | return; |
| | | } |
| | |
| | | std::this_thread::sleep_for(std::chrono::seconds(1)); |
| | | int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen, tt); |
| | | if(retLen == 0){ |
| | | logIt("do capturePic failed:%d"); |
| | | printf("do capturePic failed:%d"); |
| | | ret = -1; |
| | | } |
| | | |
| | |
| | | if (i++ > ttt) break; |
| | | } |
| | | t.detach(); |
| | | return -1; |
| | | return -3; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // GetGBJpg Get GB28181 Jpg |
| | | func GetGBJpg(rtspURL string, maxTry int) []byte { |
| | | func GetGBJpg(rtspURL string, maxTry int) ([]byte, int) { |
| | | 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, C.int(maxTry)) |
| | | defer C.free(unsafe.Pointer(pic)) |
| | | var pic unsafe.Pointer |
| | | ret := C.wrap_fn_get_gb28181_pic(unsafe.Pointer(libcffmpeg), rtsp, &pic, &jpgLen, C.int(maxTry)) |
| | | if ret <= 0 { |
| | | return nil, int(ret) |
| | | } |
| | | defer C.free(pic) |
| | | |
| | | retJpg := C.GoBytes(unsafe.Pointer(pic), jpgLen) |
| | | return retJpg |
| | | return retJpg, int(ret) |
| | | } |
| | |
| | | fn_gb28181(h); |
| | | } |
| | | |
| | | char * wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, int *retDataLen, const int tt){ |
| | | int wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, void** ret, 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) { |
| | |
| | | return NULL; |
| | | } |
| | | } |
| | | return fn_get_gb28181_pic(rtspUrl, retDataLen, tt); |
| | | return fn_get_gb28181_pic(rtspUrl, (char**)ret, retDataLen, tt); |
| | | } |
| | | |
| | | void wrap_fn_use_cpu(void *lib, const cffmpeg h){ |
| | |
| | | typedef void (*lib_cffmpeg_run)(const cffmpeg, const char*); |
| | | typedef int (*lib_cffmpeg_fps)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_gb28181)(const cffmpeg); |
| | | typedef char * (*lib_cffmpeg_get_gb28181_pic)(const char *rtspUrl, int *retDataLen, const int); |
| | | typedef int (*lib_cffmpeg_get_gb28181_pic)(const char *rtspUrl, char**, int *retDataLen, const int); |
| | | typedef void (*lib_cffmpeg_cpu)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_open_recorder)(const cffmpeg); |
| | | typedef void (*lib_cffmpeg_rec_duration)(const cffmpeg, const int, const int); |
| | |
| | | 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, const int tt); |
| | | int wrap_fn_get_gb28181_pic(void *lib, const char *rtspUrl, void** ret, 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); |