video analysis2.0拆分,ffmpeg封装go接口库
chenshijun
2019-07-29 d2bec7c45f71a12734b359f10bda6302ecd8a657
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){
@@ -93,23 +103,6 @@
    s->GetPacket(&data, size, key);
    return data;
}
/////////////////////active api
void c_ffmpeg_active_recorder(const cffmpeg h, const char *dir, int mind, int maxd,
                                    rec_func fn){
    Wrapper *s = (Wrapper*)h;
    s->ActiveRecorder(dir, mind, maxd,[fn](std::string &p, int &i){
        fn((char*)p.c_str(), i);
    });
}
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){