| | |
| | | { |
| | | rec::rec() |
| | | :recRef_(NULL) |
| | | ,minduration_(250) |
| | | ,maxduration_(750) |
| | | ,min_cache_len_(125) |
| | | ,time_offset_(4) |
| | | {} |
| | | |
| | | rec::~rec() |
| | |
| | | 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()){ |
| | |
| | | shrinkCache(); |
| | | } |
| | | |
| | | void rec::SetRecMinCacheTime(const int min){ |
| | | // 由于整个流程耗时,补偿time_offset_,因为是最小的一半,只有time_offset_/2 |
| | | min_cache_len_ = (min + time_offset_) * recRef_->getFPS(); |
| | | } |
| | | |
| | | int rec::shrinkCache(){ |
| | | //超过最大缓存,丢弃gop |
| | | //缓存最小长度的,用于记录 |
| | | int md = minduration_ < 201 ? 200 : minduration_; |
| | | int md = min_cache_len_ < 200 ? 200 : min_cache_len_; |
| | | while (list_pkt_.size() > md/2) { |
| | | list_pkt_.pop_front(); |
| | | while(!list_pkt_.empty()){ |