From 4eab3ca9bf020df2bb53fa2a36aa4f57d684225c Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期三, 07 八月 2019 17:25:03 +0800 Subject: [PATCH] add rec notify, try catch --- csrc/cffmpeg.cpp | 50 +++++++++++++++++++++++++------------------------- 1 files changed, 25 insertions(+), 25 deletions(-) diff --git a/csrc/cffmpeg.cpp b/csrc/cffmpeg.cpp index b78313e..3383b31 100644 --- a/csrc/cffmpeg.cpp +++ b/csrc/cffmpeg.cpp @@ -48,14 +48,14 @@ //////passive api -void c_ffmpeg_build_recorder(const cffmpeg h, const char *dir, int mind, int maxd){ +void c_ffmpeg_build_recorder(const cffmpeg h, const char* id, const char *dir, int mind, int maxd){ Wrapper *s = (Wrapper*)h; - s->BuildRecorder(dir, mind, maxd); + s->BuildRecorder(id, dir, mind, maxd); } -void c_ffmpeg_fire_recorder(const cffmpeg h, const int64_t id){ +void c_ffmpeg_fire_recorder(const cffmpeg h, const char* sid, const int64_t id){ Wrapper *s = (Wrapper*)h; - s->FireRecorder(id); + s->FireRecorder(sid, id); } char* c_ffmpeg_get_info_recorder(const cffmpeg h, int *index, int *length){ @@ -63,16 +63,26 @@ int i; std::string p; s->GetInfoRecorder(i, p); - if(i < 0){ - return NULL; - } + + // printf("cffmpeg get info : index : %d, file : %s\n", i, p.c_str()); + *index = i; *length = p.length(); char *path = (char*)malloc(*length + 1); memcpy(path, p.c_str(), *length); path[*length] = '\0'; - + return path; +} + +char* c_ffmpeg_get_rec_id(const cffmpeg h, const char* p, int *length){ + Wrapper *s = (Wrapper*)h; + std::string id = s->GetRecorderID(p); + *length = id.length(); + char *i = (char*)malloc(*length+1); + memcpy(i, id.c_str(), *length); + i[*length] = '\0'; + return i; } void c_ffmpeg_build_decoder(const cffmpeg h){ @@ -80,29 +90,19 @@ s->BuildDecoder(); } -void* c_ffmpeg_get_pic_decoder(const cffmpeg h, int *wid, int *hei){ +void* c_ffmpeg_get_pic_decoder(const cffmpeg h, int *wid, int *hei, int64_t *id){ Wrapper *s = (Wrapper*)h; unsigned char *data = NULL; - s->GetPicDecoder(&data, wid, hei); + s->GetPicDecoder(&data, wid, hei, id); return data; } -/////////////////////active api -void c_ffmpeg_active_recorder(const cffmpeg h, const char *dir, int mind, int maxd, - rec_func fn){ + +void* c_ffmpeg_get_avpacket(const cffmpeg h, int *size, int *key){ Wrapper *s = (Wrapper*)h; - - s->ActiveRecorder(dir, mind, maxd,[fn](std::string &p, int &i){ - fn((char*)p.c_str(), i); - }); + unsigned char *data = NULL; + s->GetPacket(&data, size, key); + return data; } - -void c_ffmpeg_active_decoder(const cffmpeg h, dec_func fn){ - Wrapper *s = (Wrapper*)h; - s->ActiveDecoder([fn](void* d, int wid, int hei){ - fn(d, wid, hei); - }); -} - /////////////////////test void* c_ffmpeg_decode_jpeg(const cffmpeg h, const char *file, int *wid, int *hei){ -- Gitblit v1.8.0