Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
58b829b1
提交
58b829b1
authored
9月 12, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
1416597d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
102 行增加
和
102 行删除
+102
-102
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+3
-3
evdaemon.cpp
opencv-motion-detect/evdaemon.cpp
+6
-6
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+10
-10
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+18
-18
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+19
-19
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+21
-21
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+25
-25
没有找到文件。
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
58b829b1
...
@@ -29,7 +29,7 @@ using namespace zmqhelper;
...
@@ -29,7 +29,7 @@ using namespace zmqhelper;
class
EvCloudSvc
{
class
EvCloudSvc
{
private
:
private
:
Server
svr
;
Server
svr
;
void
*
pRouterCtx
=
NULL
,
*
pRouter
=
NULL
;
void
*
pRouterCtx
=
nullptr
,
*
pRouter
=
nullptr
;
string
httpPort
=
"8089"
;
string
httpPort
=
"8089"
;
string
msgPort
=
"5548"
;
string
msgPort
=
"5548"
;
string
devSn
=
"evcloudsvc"
;
string
devSn
=
"evcloudsvc"
;
...
@@ -557,12 +557,12 @@ public:
...
@@ -557,12 +557,12 @@ public:
int
ret
=
0
;
int
ret
=
0
;
spdlog
::
info
(
"evcloudsvc boot"
);
spdlog
::
info
(
"evcloudsvc boot"
);
char
*
strEnv
=
getenv
(
"HTTP_PORT"
);
char
*
strEnv
=
getenv
(
"HTTP_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
httpPort
=
strEnv
;
httpPort
=
strEnv
;
}
}
strEnv
=
getenv
(
"MSG_PORT"
);
strEnv
=
getenv
(
"MSG_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
msgPort
=
strEnv
;
msgPort
=
strEnv
;
}
}
...
...
opencv-motion-detect/evdaemon.cpp
浏览文件 @
58b829b1
...
@@ -55,8 +55,8 @@ class EvDaemon{
...
@@ -55,8 +55,8 @@ class EvDaemon{
json
mapModsToPids
;
json
mapModsToPids
;
// for zmq
// for zmq
void
*
pRouterCtx
=
NULL
,
*
pRouter
=
NULL
;
void
*
pRouterCtx
=
nullptr
,
*
pRouter
=
nullptr
;
void
*
pDealerCtx
=
NULL
,
*
pDealer
=
NULL
;
void
*
pDealerCtx
=
nullptr
,
*
pDealer
=
nullptr
;
string
cloudAddr
=
"tcp://127.0.0.1:5548"
;
string
cloudAddr
=
"tcp://127.0.0.1:5548"
;
/// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc.
/// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc.
...
@@ -491,19 +491,19 @@ class EvDaemon{
...
@@ -491,19 +491,19 @@ class EvDaemon{
devSn
=
info
[
"sn"
];
devSn
=
info
[
"sn"
];
char
*
strEnv
=
getenv
(
"BOOTSTRAP"
);
char
*
strEnv
=
getenv
(
"BOOTSTRAP"
);
if
(
strEnv
!=
NULL
&&
memcmp
(
strEnv
,
"false"
,
5
)
==
0
)
{
if
(
strEnv
!=
nullptr
&&
memcmp
(
strEnv
,
"false"
,
5
)
==
0
)
{
bBootstrap
=
false
;
bBootstrap
=
false
;
}
}
// http port
// http port
strEnv
=
getenv
(
"DAEMON_PORT"
);
strEnv
=
getenv
(
"DAEMON_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
port
=
stoi
(
strEnv
);
port
=
stoi
(
strEnv
);
}
}
// zmq router port
// zmq router port
strEnv
=
getenv
(
"ROUTER_PORT"
);
strEnv
=
getenv
(
"ROUTER_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
portRouter
=
stoi
(
strEnv
);
portRouter
=
stoi
(
strEnv
);
}
}
...
@@ -533,7 +533,7 @@ class EvDaemon{
...
@@ -533,7 +533,7 @@ class EvDaemon{
// dealer port
// dealer port
strEnv
=
getenv
(
"CLOUD_ADDR"
);
strEnv
=
getenv
(
"CLOUD_ADDR"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
cloudAddr
=
strEnv
;
cloudAddr
=
strEnv
;
}
}
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
58b829b1
...
@@ -37,9 +37,9 @@ using namespace zmqhelper;
...
@@ -37,9 +37,9 @@ using namespace zmqhelper;
class
EvMgr
:
public
TinyThread
{
class
EvMgr
:
public
TinyThread
{
private
:
private
:
void
*
pRouterCtx
=
NULL
;
void
*
pRouterCtx
=
nullptr
;
void
*
pRouter
=
NULL
;
void
*
pRouter
=
nullptr
;
void
*
pCtxDealer
=
NULL
,
*
pDealer
=
NULL
;
void
*
pCtxDealer
=
nullptr
,
*
pDealer
=
nullptr
;
json
config
;
json
config
;
string
devSn
,
ident
;
string
devSn
,
ident
;
json
peerStatus
;
json
peerStatus
;
...
@@ -127,7 +127,7 @@ private:
...
@@ -127,7 +127,7 @@ private:
return
-
1
;
return
-
1
;
}
}
json
*
mod
=
LVDB
::
findConfigModule
(
config
,
sp
[
0
],
sp
[
1
],
stoi
(
sp
[
2
]));
json
*
mod
=
LVDB
::
findConfigModule
(
config
,
sp
[
0
],
sp
[
1
],
stoi
(
sp
[
2
]));
if
(
mod
==
NULL
)
{
if
(
mod
==
nullptr
)
{
spdlog
::
warn
(
"evmgr {} failed to find module with id: {}"
,
devSn
,
selfId
);
spdlog
::
warn
(
"evmgr {} failed to find module with id: {}"
,
devSn
,
selfId
);
return
-
1
;
return
-
1
;
}
}
...
@@ -281,12 +281,12 @@ public:
...
@@ -281,12 +281,12 @@ public:
EvMgr
()
EvMgr
()
{
{
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
drport
=
strEnv
;
drport
=
strEnv
;
}
}
strEnv
=
getenv
(
"PEERID"
);
strEnv
=
getenv
(
"PEERID"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
ident
=
strEnv
;
ident
=
strEnv
;
auto
v
=
strutils
::
split
(
ident
,
':'
);
auto
v
=
strutils
::
split
(
ident
,
':'
);
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evmgr"
||
v
[
2
]
!=
"0"
)
{
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evmgr"
||
v
[
2
]
!=
"0"
)
{
...
@@ -318,13 +318,13 @@ public:
...
@@ -318,13 +318,13 @@ public:
}
}
~
EvMgr
()
~
EvMgr
()
{
{
if
(
pRouter
!=
NULL
)
{
if
(
pRouter
!=
nullptr
)
{
zmq_close
(
pRouter
);
zmq_close
(
pRouter
);
pRouter
=
NULL
;
pRouter
=
nullptr
;
}
}
if
(
pRouterCtx
!=
NULL
)
{
if
(
pRouterCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pRouterCtx
);
zmq_ctx_destroy
(
pRouterCtx
);
pRouterCtx
=
NULL
;
pRouterCtx
=
nullptr
;
}
}
}
}
};
};
...
...
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
58b829b1
...
@@ -67,13 +67,13 @@ enum EventState {
...
@@ -67,13 +67,13 @@ enum EventState {
class
EvMLMotion
:
public
TinyThread
{
class
EvMLMotion
:
public
TinyThread
{
private
:
private
:
void
*
pSubCtx
=
NULL
,
*
pDealerCtx
=
NULL
;
// for packets relay
void
*
pSubCtx
=
nullptr
,
*
pDealerCtx
=
nullptr
;
// for packets relay
void
*
pSub
=
NULL
,
*
pDealer
=
NULL
,
*
pDaemonCtx
=
NULL
,
*
pDaemon
=
NULL
;
void
*
pSub
=
nullptr
,
*
pDealer
=
nullptr
,
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
,
slicerGid
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
,
slicerGid
;
int
iid
;
int
iid
;
AVFormatContext
*
pAVFormatInput
=
NULL
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
AVCodecContext
*
pCodecCtx
=
NULL
;
AVCodecContext
*
pCodecCtx
=
nullptr
;
AVDictionary
*
pOptsRemux
=
NULL
;
AVDictionary
*
pOptsRemux
=
nullptr
;
DetectParam
detPara
=
{
25
,
500
,
-
1
,
10
,
3
,
30
,
2
};
DetectParam
detPara
=
{
25
,
500
,
-
1
,
10
,
3
,
30
,
2
};
EventState
evtState
=
EventState
::
NONE
;
EventState
evtState
=
EventState
::
NONE
;
chrono
::
system_clock
::
time_point
evtStartTm
,
evtStartTmLast
;
chrono
::
system_clock
::
time_point
evtStartTm
,
evtStartTmLast
;
...
@@ -358,12 +358,12 @@ private:
...
@@ -358,12 +358,12 @@ private:
void
freeStream
()
void
freeStream
()
{
{
if
(
pAVFormatInput
!=
NULL
)
{
if
(
pAVFormatInput
!=
nullptr
)
{
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
int
decode_packet
(
bool
detect
,
AVPacket
*
pPacket
,
AVCodecContext
*
pCodecContext
,
AVFrame
*
pFrame
)
int
decode_packet
(
bool
detect
,
AVPacket
*
pPacket
,
AVCodecContext
*
pCodecContext
,
AVFrame
*
pFrame
)
...
@@ -652,12 +652,12 @@ public:
...
@@ -652,12 +652,12 @@ public:
{
{
evtQueue
=
queue
;
evtQueue
=
queue
;
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
drport
=
strEnv
;
drport
=
strEnv
;
}
}
strEnv
=
getenv
(
"PEERID"
);
strEnv
=
getenv
(
"PEERID"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
selfId
=
strEnv
;
selfId
=
strEnv
;
auto
v
=
strutils
::
split
(
selfId
,
':'
);
auto
v
=
strutils
::
split
(
selfId
,
':'
);
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evmlmotion"
)
{
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evmlmotion"
)
{
...
@@ -691,21 +691,21 @@ public:
...
@@ -691,21 +691,21 @@ public:
};
};
~
EvMLMotion
()
~
EvMLMotion
()
{
{
if
(
pSub
!=
NULL
)
{
if
(
pSub
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pSub
=
NULL
;
pSub
=
nullptr
;
}
}
if
(
pSubCtx
!=
NULL
)
{
if
(
pSubCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSubCtx
);
zmq_ctx_destroy
(
pSubCtx
);
pSubCtx
=
NULL
;
pSubCtx
=
nullptr
;
}
}
if
(
pDealer
!=
NULL
)
{
if
(
pDealer
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pDealer
=
NULL
;
pDealer
=
nullptr
;
}
}
if
(
pDealerCtx
!=
NULL
)
{
if
(
pDealerCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSub
);
zmq_ctx_destroy
(
pSub
);
pDealerCtx
=
NULL
;
pDealerCtx
=
nullptr
;
}
}
};
};
};
};
...
...
opencv-motion-detect/evpuller.cpp
浏览文件 @
58b829b1
...
@@ -117,14 +117,14 @@ public:
...
@@ -117,14 +117,14 @@ public:
class
EvPuller
:
public
TinyThread
{
class
EvPuller
:
public
TinyThread
{
private
:
private
:
void
*
pPubCtx
=
NULL
;
// for packets publishing
void
*
pPubCtx
=
nullptr
;
// for packets publishing
void
*
pPub
=
NULL
;
void
*
pPub
=
nullptr
;
void
*
pDealerCtx
=
NULL
;
void
*
pDealerCtx
=
nullptr
;
void
*
pDealer
=
NULL
;
void
*
pDealer
=
nullptr
;
void
*
pDaemonCtx
=
NULL
,
*
pDaemon
=
NULL
;
void
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
AVFormatContext
*
pAVFormatInput
=
NULL
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
string
urlIn
,
urlPub
,
urlDealer
,
mgrSn
,
devSn
,
selfId
,
ipcPort
;
string
urlIn
,
urlPub
,
urlDealer
,
mgrSn
,
devSn
,
selfId
,
ipcPort
;
int
*
streamList
=
NULL
,
numStreams
=
0
,
iid
;
int
*
streamList
=
nullptr
,
numStreams
=
0
,
iid
;
time_t
tsLastBoot
,
tsUpdateTime
;
time_t
tsLastBoot
,
tsUpdateTime
;
json
config
;
json
config
;
string
drport
=
"5549"
;
string
drport
=
"5549"
;
...
@@ -270,7 +270,7 @@ protected:
...
@@ -270,7 +270,7 @@ protected:
}
}
// serialize formatctx to bytes
// serialize formatctx to bytes
char
*
pBytes
=
NULL
;
char
*
pBytes
=
nullptr
;
ret
=
AVFormatCtxSerializer
::
encode
(
pAVFormatInput
,
&
pBytes
);
ret
=
AVFormatCtxSerializer
::
encode
(
pAVFormatInput
,
&
pBytes
);
auto
repSrv
=
RepSrv
(
mgrSn
,
devSn
,
iid
,
pBytes
,
ret
,
pDealer
);
auto
repSrv
=
RepSrv
(
mgrSn
,
devSn
,
iid
,
pBytes
,
ret
,
pDealer
);
repSrv
.
detach
();
repSrv
.
detach
();
...
@@ -325,7 +325,7 @@ protected:
...
@@ -325,7 +325,7 @@ protected:
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
// serialize packet to raw bytes
// serialize packet to raw bytes
char
*
data
=
NULL
;
char
*
data
=
nullptr
;
int
size
=
AVPacketSerializer
::
encode
(
packet
,
&
data
);
int
size
=
AVPacketSerializer
::
encode
(
packet
,
&
data
);
zmq_msg_init_data
(
&
msg
,
(
void
*
)
data
,
size
,
mqPacketFree
,
NULL
);
zmq_msg_init_data
(
&
msg
,
(
void
*
)
data
,
size
,
mqPacketFree
,
NULL
);
zmq_send_const
(
pPub
,
zmq_msg_data
(
&
msg
),
size
,
0
);
zmq_send_const
(
pPub
,
zmq_msg_data
(
&
msg
),
size
,
0
);
...
@@ -347,12 +347,12 @@ public:
...
@@ -347,12 +347,12 @@ public:
EvPuller
()
EvPuller
()
{
{
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
drport
=
strEnv
;
drport
=
strEnv
;
}
}
strEnv
=
getenv
(
"PEERID"
);
strEnv
=
getenv
(
"PEERID"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
selfId
=
strEnv
;
selfId
=
strEnv
;
auto
v
=
strutils
::
split
(
selfId
,
':'
);
auto
v
=
strutils
::
split
(
selfId
,
':'
);
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evpuller"
)
{
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evpuller"
)
{
...
@@ -383,21 +383,21 @@ public:
...
@@ -383,21 +383,21 @@ public:
~
EvPuller
()
~
EvPuller
()
{
{
if
(
pPub
!=
NULL
)
{
if
(
pPub
!=
nullptr
)
{
zmq_close
(
pPub
);
zmq_close
(
pPub
);
pPub
=
NULL
;
pPub
=
nullptr
;
}
}
if
(
pPubCtx
!=
NULL
)
{
if
(
pPubCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pPubCtx
);
zmq_ctx_destroy
(
pPubCtx
);
pPubCtx
=
NULL
;
pPubCtx
=
nullptr
;
}
}
if
(
pDealer
!=
NULL
)
{
if
(
pDealer
!=
nullptr
)
{
zmq_close
(
pDealer
);
zmq_close
(
pDealer
);
pDealer
=
NULL
;
pDealer
=
nullptr
;
}
}
if
(
pDealerCtx
!=
NULL
)
{
if
(
pDealerCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pPubCtx
);
zmq_ctx_destroy
(
pPubCtx
);
pDealerCtx
=
NULL
;
pDealerCtx
=
nullptr
;
}
}
}
}
};
};
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
58b829b1
...
@@ -38,14 +38,14 @@ using namespace zmqhelper;
...
@@ -38,14 +38,14 @@ using namespace zmqhelper;
class
EvPusher
:
public
TinyThread
{
class
EvPusher
:
public
TinyThread
{
private
:
private
:
void
*
pSubCtx
=
NULL
,
*
pDealerCtx
=
NULL
;
// for packets relay
void
*
pSubCtx
=
nullptr
,
*
pDealerCtx
=
nullptr
;
// for packets relay
void
*
pSub
=
NULL
,
*
pDealer
=
NULL
,
*
pDaemonCtx
=
NULL
,
*
pDaemon
=
NULL
;
void
*
pSub
=
nullptr
,
*
pDealer
=
nullptr
,
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
string
urlOut
,
urlPub
,
urlDealer
,
devSn
,
pullerGid
,
mgrSn
,
selfId
;
string
urlOut
,
urlPub
,
urlDealer
,
devSn
,
pullerGid
,
mgrSn
,
selfId
;
int
iid
;
int
iid
;
bool
enablePush
=
false
;
bool
enablePush
=
false
;
int
*
streamList
=
NULL
;
int
*
streamList
=
nullptr
;
AVFormatContext
*
pAVFormatRemux
=
NULL
;
AVFormatContext
*
pAVFormatRemux
=
nullptr
;
AVFormatContext
*
pAVFormatInput
=
NULL
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
time_t
tsLastBoot
,
tsUpdateTime
;
time_t
tsLastBoot
,
tsUpdateTime
;
json
config
;
json
config
;
thread
thPing
;
thread
thPing
;
...
@@ -220,7 +220,7 @@ private:
...
@@ -220,7 +220,7 @@ private:
int
setupStream
()
int
setupStream
()
{
{
int
ret
=
0
;
int
ret
=
0
;
AVDictionary
*
pOptsRemux
=
NULL
;
AVDictionary
*
pOptsRemux
=
nullptr
;
ret
=
avformat_alloc_output_context2
(
&
pAVFormatRemux
,
NULL
,
"rtsp"
,
urlOut
.
c_str
());
ret
=
avformat_alloc_output_context2
(
&
pAVFormatRemux
,
NULL
,
"rtsp"
,
urlOut
.
c_str
());
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -300,14 +300,14 @@ private:
...
@@ -300,14 +300,14 @@ private:
avformat_free_context
(
pAVFormatRemux
);
avformat_free_context
(
pAVFormatRemux
);
}
}
pAVFormatRemux
=
NULL
;
pAVFormatRemux
=
nullptr
;
// free avformatcontex
// free avformatcontex
if
(
pAVFormatInput
!=
NULL
)
{
if
(
pAVFormatInput
!=
nullptr
)
{
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
protected
:
protected
:
void
run
()
void
run
()
...
@@ -357,7 +357,7 @@ protected:
...
@@ -357,7 +357,7 @@ protected:
spdlog
::
debug
(
"packet stream indx: {:d}"
,
packet
.
stream_index
);
spdlog
::
debug
(
"packet stream indx: {:d}"
,
packet
.
stream_index
);
// relay
// relay
AVStream
*
in_stream
=
NULL
,
*
out_stream
=
NULL
;
AVStream
*
in_stream
=
NULL
,
*
out_stream
=
nullptr
;
in_stream
=
pAVFormatInput
->
streams
[
packet
.
stream_index
];
in_stream
=
pAVFormatInput
->
streams
[
packet
.
stream_index
];
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
out_stream
=
pAVFormatRemux
->
streams
[
packet
.
stream_index
];
out_stream
=
pAVFormatRemux
->
streams
[
packet
.
stream_index
];
...
@@ -406,12 +406,12 @@ public:
...
@@ -406,12 +406,12 @@ public:
EvPusher
()
EvPusher
()
{
{
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
drport
=
strEnv
;
drport
=
strEnv
;
}
}
strEnv
=
getenv
(
"PEERID"
);
strEnv
=
getenv
(
"PEERID"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
selfId
=
strEnv
;
selfId
=
strEnv
;
auto
v
=
strutils
::
split
(
selfId
,
':'
);
auto
v
=
strutils
::
split
(
selfId
,
':'
);
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evpusher"
)
{
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evpusher"
)
{
...
@@ -445,21 +445,21 @@ public:
...
@@ -445,21 +445,21 @@ public:
~
EvPusher
()
~
EvPusher
()
{
{
if
(
pSub
!=
NULL
)
{
if
(
pSub
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pSub
=
NULL
;
pSub
=
nullptr
;
}
}
if
(
pSubCtx
!=
NULL
)
{
if
(
pSubCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSubCtx
);
zmq_ctx_destroy
(
pSubCtx
);
pSubCtx
=
NULL
;
pSubCtx
=
nullptr
;
}
}
if
(
pDealer
!=
NULL
)
{
if
(
pDealer
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pDealer
=
NULL
;
pDealer
=
nullptr
;
}
}
if
(
pDealerCtx
!=
NULL
)
{
if
(
pDealerCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSub
);
zmq_ctx_destroy
(
pSub
);
pDealerCtx
=
NULL
;
pDealerCtx
=
nullptr
;
}
}
freeStream
();
freeStream
();
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
58b829b1
...
@@ -43,17 +43,17 @@ private:
...
@@ -43,17 +43,17 @@ private:
#define MINUTES_PER_SLICE_DEFAULT 2
#define MINUTES_PER_SLICE_DEFAULT 2
// 2 days, 10 minutes per record
// 2 days, 10 minutes per record
#define NUM_SLICES_DEFAULT (24 * NUM_DAYS_DEFAULT * 60 / MINUTES_PER_SLICE_DEFAULT)
#define NUM_SLICES_DEFAULT (24 * NUM_DAYS_DEFAULT * 60 / MINUTES_PER_SLICE_DEFAULT)
void
*
pSubCtx
=
NULL
,
*
pDealerCtx
=
NULL
;
// for packets relay
void
*
pSubCtx
=
nullptr
,
*
pDealerCtx
=
nullptr
;
// for packets relay
void
*
pSub
=
NULL
,
*
pDealer
=
NULL
,
*
pDaemonCtx
=
NULL
,
*
pDaemon
=
NULL
;
void
*
pSub
=
nullptr
,
*
pDealer
=
nullptr
,
*
pDaemonCtx
=
nullptr
,
*
pDaemon
=
nullptr
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
;
string
urlOut
,
urlPub
,
urlRouter
,
devSn
,
mgrSn
,
selfId
,
pullerGid
;
int
iid
,
days
,
minutes
,
numSlices
,
lastSliceId
;
int
iid
,
days
,
minutes
,
numSlices
,
lastSliceId
;
bool
enablePush
=
false
;
bool
enablePush
=
false
;
AVFormatContext
*
pAVFormatRemux
=
NULL
;
AVFormatContext
*
pAVFormatRemux
=
nullptr
;
AVFormatContext
*
pAVFormatInput
=
NULL
;
AVFormatContext
*
pAVFormatInput
=
nullptr
;
AVDictionary
*
pOptsRemux
=
NULL
;
AVDictionary
*
pOptsRemux
=
nullptr
;
// load from db
// load from db
vector
<
int
>
*
sliceIdxToName
=
NULL
;
vector
<
int
>
*
sliceIdxToName
=
nullptr
;
int
*
streamList
=
NULL
;
int
*
streamList
=
nullptr
;
time_t
tsLastBoot
,
tsUpdateTime
;
time_t
tsLastBoot
,
tsUpdateTime
;
json
config
;
json
config
;
thread
thPing
;
thread
thPing
;
...
@@ -296,14 +296,14 @@ private:
...
@@ -296,14 +296,14 @@ private:
avformat_free_context
(
pAVFormatRemux
);
avformat_free_context
(
pAVFormatRemux
);
}
}
pAVFormatRemux
=
NULL
;
pAVFormatRemux
=
nullptr
;
// free avformatcontex
// free avformatcontex
if
(
pAVFormatInput
!=
NULL
)
{
if
(
pAVFormatInput
!=
nullptr
)
{
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
pAVFormatInput
=
NULL
;
pAVFormatInput
=
nullptr
;
}
}
protected
:
protected
:
...
@@ -313,7 +313,7 @@ protected:
...
@@ -313,7 +313,7 @@ protected:
int
ret
=
0
;
int
ret
=
0
;
int
idx
=
0
;
int
idx
=
0
;
int
pktCnt
=
0
;
int
pktCnt
=
0
;
AVStream
*
out_stream
=
NULL
;
AVStream
*
out_stream
=
nullptr
;
zmq_msg_t
msg
;
zmq_msg_t
msg
;
AVPacket
packet
;
AVPacket
packet
;
while
(
true
)
{
while
(
true
)
{
...
@@ -386,7 +386,7 @@ protected:
...
@@ -386,7 +386,7 @@ protected:
zmq_msg_close
(
&
msg
);
zmq_msg_close
(
&
msg
);
AVStream
*
in_stream
=
NULL
,
*
out_stream
=
NULL
;
AVStream
*
in_stream
=
NULL
,
*
out_stream
=
nullptr
;
in_stream
=
pAVFormatInput
->
streams
[
packet
.
stream_index
];
in_stream
=
pAVFormatInput
->
streams
[
packet
.
stream_index
];
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
packet
.
stream_index
=
streamList
[
packet
.
stream_index
];
out_stream
=
pAVFormatRemux
->
streams
[
packet
.
stream_index
];
out_stream
=
pAVFormatRemux
->
streams
[
packet
.
stream_index
];
...
@@ -431,8 +431,8 @@ protected:
...
@@ -431,8 +431,8 @@ protected:
}
// while in slice
}
// while in slice
// write tail
// write tail
// close output context
// close output context
if
(
pAVFormatRemux
!=
NULL
)
{
if
(
pAVFormatRemux
!=
nullptr
)
{
if
(
pAVFormatRemux
->
pb
!=
NULL
)
{
if
(
pAVFormatRemux
->
pb
!=
nullptr
)
{
avio_closep
(
&
pAVFormatRemux
->
pb
);
avio_closep
(
&
pAVFormatRemux
->
pb
);
}
}
avformat_free_context
(
pAVFormatRemux
);
avformat_free_context
(
pAVFormatRemux
);
...
@@ -443,12 +443,12 @@ public:
...
@@ -443,12 +443,12 @@ public:
EvSlicer
()
EvSlicer
()
{
{
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
const
char
*
strEnv
=
getenv
(
"DR_PORT"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
drport
=
strEnv
;
drport
=
strEnv
;
}
}
strEnv
=
getenv
(
"PEERID"
);
strEnv
=
getenv
(
"PEERID"
);
if
(
strEnv
!=
NULL
)
{
if
(
strEnv
!=
nullptr
)
{
selfId
=
strEnv
;
selfId
=
strEnv
;
auto
v
=
strutils
::
split
(
selfId
,
':'
);
auto
v
=
strutils
::
split
(
selfId
,
':'
);
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evslicer"
)
{
if
(
v
.
size
()
!=
3
||
v
[
1
]
!=
"evslicer"
)
{
...
@@ -481,21 +481,21 @@ public:
...
@@ -481,21 +481,21 @@ public:
};
};
~
EvSlicer
()
~
EvSlicer
()
{
{
if
(
pSub
!=
NULL
)
{
if
(
pSub
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pSub
=
NULL
;
pSub
=
nullptr
;
}
}
if
(
pSubCtx
!=
NULL
)
{
if
(
pSubCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSubCtx
);
zmq_ctx_destroy
(
pSubCtx
);
pSubCtx
=
NULL
;
pSubCtx
=
nullptr
;
}
}
if
(
pDealer
!=
NULL
)
{
if
(
pDealer
!=
nullptr
)
{
zmq_close
(
pSub
);
zmq_close
(
pSub
);
pDealer
=
NULL
;
pDealer
=
nullptr
;
}
}
if
(
pDealerCtx
!=
NULL
)
{
if
(
pDealerCtx
!=
nullptr
)
{
zmq_ctx_destroy
(
pSub
);
zmq_ctx_destroy
(
pSub
);
pDealerCtx
=
NULL
;
pDealerCtx
=
nullptr
;
}
}
freeStream
();
freeStream
();
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论