From 88c21b872799a1ae9dd7dd7d20f3811d749d9418 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 26 七月 2019 14:04:22 +0800
Subject: [PATCH] add rec

---
 csrc/cffmpeg.cpp |   61 +++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/csrc/cffmpeg.cpp b/csrc/cffmpeg.cpp
index 2bf0a0f..956d33c 100644
--- a/csrc/cffmpeg.cpp
+++ b/csrc/cffmpeg.cpp
@@ -31,31 +31,52 @@
     s->RunStream(input);
 }
 
+void c_ffmpeg_scale(const cffmpeg h, const int wid, const int hei, const int flags){
+    Wrapper *s = (Wrapper*)h;
+    s->ScalePicture(wid, hei, flags);
+}
+
+void c_ffmpeg_run_gb28181(const cffmpeg h){
+    Wrapper *s = (Wrapper*)h;
+    s->UseGB28181();
+}
+
+void c_ffmepg_use_cpu(const cffmpeg h){
+    Wrapper *s = (Wrapper*)h;
+    s->UseCPU();
+}
+
+
 //////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){
+char* c_ffmpeg_get_info_recorder(const cffmpeg h, char **sid, int *index, int *length){
     Wrapper *s = (Wrapper*)h;
     int i;
     std::string p;
-    s->GetInfoRecorder(i, p);
-    if(i < 0){
-        return NULL;
-    }
+    std::string id;
+    s->GetInfoRecorder(id, i, p);
+
+    // 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';
 
+    *sid = (char*)malloc(id.length()+1);
+    memcpy(*sid, id.c_str(), id.length());
+    *sid[id.length()] = '\0';
+    
     return path;
 }
 
@@ -68,6 +89,13 @@
     Wrapper *s = (Wrapper*)h;
     unsigned char *data = NULL;
     s->GetPicDecoder(&data, wid, hei);
+    return data;
+}
+
+void* c_ffmpeg_get_avpacket(const cffmpeg h, int *size, int *key){
+    Wrapper *s = (Wrapper*)h;
+    unsigned char *data = NULL;
+    s->GetPacket(&data, size, key);
     return data;
 }
 /////////////////////active api
@@ -96,4 +124,17 @@
         *wid = *hei = 0;
     }
     return p;
-}
\ No newline at end of file
+}
+
+// pic encoder
+void *c_ffmpeg_create_encoder(const int w, const int h, const int fps, const int br, const int scale_flag, const int gi){
+    return CreateEncoder(w, h, fps, br, scale_flag, gi);
+}
+
+void c_ffmpeg_destroy_encoder(void *h){
+    DestroyEncoder(h);
+}
+
+int c_ffmpeg_encode(void *hdl, uint8_t *in, const int w, const int h, uint8_t **out, int *size, int *key){
+    return Encode(hdl, in, w, h, out, size, key);
+}

--
Gitblit v1.8.0