bug fixed gb28181 capture picture
| | |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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"); |
| | |
| | | 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; |
| | | |
| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | // 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) |
| | |
| | | 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) { |
| | |
| | | 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){ |
| | |
| | | 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); |