Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
cdeae768
提交
cdeae768
authored
1月 17, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
evpuller: monitor thread
上级
dc01345c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
10 行删除
+23
-10
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+23
-10
没有找到文件。
opencv-motion-detect/evpuller.cpp
浏览文件 @
cdeae768
...
@@ -37,12 +37,13 @@ private:
...
@@ -37,12 +37,13 @@ private:
string
urlIn
,
urlPub
,
urlDealer
,
mgrSn
,
devSn
,
selfId
,
ipcPort
;
string
urlIn
,
urlPub
,
urlDealer
,
mgrSn
,
devSn
,
selfId
,
ipcPort
;
int
numStreams
=
0
,
iid
;
int
numStreams
=
0
,
iid
;
json
config
;
json
config
;
thread
thEdgeMsgHandler
,
thCloudMsgHandler
;
thread
thEdgeMsgHandler
,
thCloudMsgHandler
,
thMonitor
;
string
proto
=
"rtsp"
;
string
proto
=
"rtsp"
;
string
drport
=
"5549"
;
string
drport
=
"5549"
;
condition_variable
cvMsg
;
condition_variable
cvMsg
;
mutex
mutMsg
;
mutex
mutMsg
;
bool
gotFormat
=
false
;
bool
gotFormat
=
false
;
uint64_t
pktCnt
=
0
;
int
handleCloudMsg
(
vector
<
vector
<
uint8_t
>
>
v
)
int
handleCloudMsg
(
vector
<
vector
<
uint8_t
>
>
v
)
{
{
...
@@ -313,7 +314,20 @@ protected:
...
@@ -313,7 +314,20 @@ protected:
// const char * userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.0 Safari/537.36";
// const char * userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.0 Safari/537.36";
// av_dict_set(&optsIn, "r", "18", 0);
// av_dict_set(&optsIn, "r", "18", 0);
// av_dict_set(&optsIn, "user-agent", userAgent, 0);
// av_dict_set(&optsIn, "user-agent", userAgent, 0);
// monitor thread
thMonitor
=
thread
([
this
]
{
uint64_t
pktCntLast
=
this
->
pktCnt
;
while
(
1
)
{
this_thread
::
sleep_for
(
chrono
::
seconds
(
30
));
if
(
pktCntLast
==
this
->
pktCnt
)
{
spdlog
::
error
(
"{} failed read packet in 30s, restart"
,
selfId
);
kill
(
getpid
(),
SIGTERM
);
}
pktCntLast
=
this
->
pktCnt
;
}
});
spdlog
::
info
(
"{} openning stream: {}"
,
selfId
,
urlIn
);
spdlog
::
info
(
"{} openning stream: {}"
,
selfId
,
urlIn
);
if
((
ret
=
avformat_open_input
(
&
pAVFormatInput
,
urlIn
.
c_str
(),
NULL
,
&
optsIn
))
<
0
)
{
if
((
ret
=
avformat_open_input
(
&
pAVFormatInput
,
urlIn
.
c_str
(),
NULL
,
&
optsIn
))
<
0
)
{
...
@@ -386,13 +400,12 @@ protected:
...
@@ -386,13 +400,12 @@ protected:
}
}
bool
bStopSig
=
false
;
bool
bStopSig
=
false
;
uint64_t
pktCnt
=
0
;
spdlog
::
info
(
"evpulelr {} reading packets from {}"
,
selfId
,
urlIn
);
spdlog
::
info
(
"evpulelr {} reading packets from {}"
,
selfId
,
urlIn
);
while
(
true
)
{
while
(
true
)
{
if
(
checkStop
()
==
true
)
{
//
if(checkStop() == true) {
bStopSig
=
true
;
//
bStopSig = true;
break
;
//
break;
}
//
}
// if(1 == getppid()) {
// if(1 == getppid()) {
// spdlog::error("{} exit since evdaemon is dead", selfId);
// spdlog::error("{} exit since evdaemon is dead", selfId);
...
@@ -496,9 +509,9 @@ public:
...
@@ -496,9 +509,9 @@ public:
spdlog
::
info
(
"{} boot"
,
selfId
);
spdlog
::
info
(
"{} boot"
,
selfId
);
SingletonProcess
self
(
selfName
,
iid
);
SingletonProcess
self
(
selfName
,
iid
);
if
(
!
self
()){
if
(
!
self
())
{
spdlog
::
error
(
"{} already running. ignore this instance"
,
selfId
);
spdlog
::
error
(
"{} already running. ignore this instance"
,
selfId
);
exit
(
0
);
exit
(
0
);
}
}
//
//
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论