From 52b0ef0b8d617de555808f6e2dbeffa311711155 Mon Sep 17 00:00:00 2001
From: 554325746@qq.com <554325746@qq.com>
Date: 星期一, 09 三月 2020 16:48:00 +0800
Subject: [PATCH] local file quit signal
---
csrc/wrapper.cpp | 30 +++++++++++++++++++++++++++---
csrc/wrapper.hpp | 1 +
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp
index 3e34b2c..5e50469 100644
--- a/csrc/wrapper.cpp
+++ b/csrc/wrapper.cpp
@@ -55,6 +55,7 @@
,rec_(new rec)
,logit_(false)
,fps_(25)
+ ,file_finished_(false)
{
makeTheWorld();
}
@@ -73,6 +74,8 @@
,decoder_(nullptr)
,rec_(new rec)
,logit_(true)
+ ,fps_(25)
+ ,file_finished_(false)
{
makeTheWorld();
logif::CreateLogger(logfile, true);
@@ -199,9 +202,12 @@
fps_ = in->getFPS();
- int wTime = 1000000.0 / in->getFPS() ;
+ if (fps_ < 1 || fps_ > 200){
+ fps_ = 25;
+ }
+
+ int wTime = 1000000.0 / fps_ ;
wTime >>= 1;
- logIt("WAIT TIME PER FRAME: %d", wTime);
init_worker(in.get());
@@ -210,6 +216,11 @@
int64_t a_id = id;
bool exist = access(input_url_.c_str(), 0) == 0;
+ if (exist){
+ wTime <<= 1;
+ }
+
+ logIt("WAIT TIME PER FRAME: %d", wTime);
while(!stop_stream_.load()){
auto data(std::make_shared<CodedData>());
@@ -248,7 +259,11 @@
}
deinit_worker();
- if (exist) break;
+ if (exist) {
+ logIt("local file exist");
+ file_finished_ = true;
+ break;
+ }
}
}
@@ -289,6 +304,15 @@
}
void Wrapper::GetPicDecoder(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id){
+ if (file_finished_){
+ *data = (unsigned char*)this;
+ *w = 1080;
+ *h = 720;
+ *format = 23;
+ *length = 12;
+ *id = -10802020;
+ return;
+ }
if (decoder_){
decoder_->GetFrame(data, w, h, format, length, id);
}
diff --git a/csrc/wrapper.hpp b/csrc/wrapper.hpp
index 43e3f61..575197d 100644
--- a/csrc/wrapper.hpp
+++ b/csrc/wrapper.hpp
@@ -82,6 +82,7 @@
std::function<void()> fn_rec_lazy_;
bool logit_;
int fps_;
+ bool file_finished_;
};
void *CreateEncoder(const int w, const int h, const int fps, const int br,
--
Gitblit v1.8.0