From 7e6f863a5928b8481975e9fdf6460dde2c0b14bf Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期六, 19 十月 2019 14:29:39 +0800
Subject: [PATCH] remove files

---
 csrc/worker/rec.cpp |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/csrc/worker/rec.cpp b/csrc/worker/rec.cpp
index 01896b0..2e02903 100644
--- a/csrc/worker/rec.cpp
+++ b/csrc/worker/rec.cpp
@@ -20,8 +20,8 @@
 {
     rec::rec()
     :recRef_(NULL)
-    ,minduration_(250)
-    ,maxduration_(750)
+    ,min_cache_len_(125)
+    ,time_offset_(5)
     {}
 
     rec::~rec()
@@ -141,9 +141,6 @@
         std::string rid(id);
         std::string dir(output);
         
-        minduration_ = mindur * recRef_->getFPS();
-        maxduration_ = maxdur * recRef_->getFPS();
-
         {
             std::lock_guard<std::mutex> l(mtx_rec_);
             if (map_rec_.find(rid) != map_rec_.end()){
@@ -197,11 +194,26 @@
         shrinkCache();
     }
 
+    void rec::SetRecMinCacheTime(const int min){
+        // 鐢变簬鏁翠釜娴佺▼鑰楁椂,琛ュ伩time_offset_
+        int fps = 25;
+        if (recRef_){
+            fps = recRef_->getFPS();
+        }
+        min_cache_len_ = (min + time_offset_) * fps;
+    }
+
     int rec::shrinkCache(){
         //瓒呰繃鏈�澶х紦瀛�,涓㈠純gop
         //缂撳瓨鏈�灏忛暱搴︾殑,鐢ㄤ簬璁板綍
-        int md = minduration_ < 201 ? 200 : minduration_;
-        while (list_pkt_.size() > md/2) {
+        int fps = 25;
+        if (recRef_){
+            fps = recRef_->getFPS();
+        }
+        // 鏈�灏�5绉掗暱搴�
+        int mincache = fps * 5;
+        int md = min_cache_len_ < mincache ? mincache : min_cache_len_;
+        while (list_pkt_.size() > md) {
             list_pkt_.pop_front();
             while(!list_pkt_.empty()){
                 auto &i = list_pkt_.front();

--
Gitblit v1.8.0