Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
0c5338a4
提交
0c5338a4
authored
10月 18, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: online update
上级
fd1202d8
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
16 行删除
+25
-16
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+15
-7
postfile.cpp
opencv-motion-detect/postfile.cpp
+7
-6
postfile.h
opencv-motion-detect/postfile.h
+3
-3
没有找到文件。
opencv-motion-detect/evslicer.cpp
浏览文件 @
0c5338a4
...
@@ -964,8 +964,13 @@ public:
...
@@ -964,8 +964,13 @@ public:
spdlog
::
error
(
"evslicer {} thEventHandler event ({}, {}) = ({}, {}) not in range: ({}, {}), ({}, {})"
,
this
->
selfId
,
tss
,
tse
,
this
->
videoFileTs2Name
(
tss
),
this
->
videoFileTs2Name
(
tse
),
first
,
end
,
this
->
videoFileTs2Name
(
first
),
this
->
videoFileTs2Name
(
end
));
spdlog
::
error
(
"evslicer {} thEventHandler event ({}, {}) = ({}, {}) not in range: ({}, {}), ({}, {})"
,
this
->
selfId
,
tss
,
tse
,
this
->
videoFileTs2Name
(
tss
),
this
->
videoFileTs2Name
(
tse
),
first
,
end
,
this
->
videoFileTs2Name
(
first
),
this
->
videoFileTs2Name
(
end
));
}
}
else
{
else
{
vector
<
tuple
<
string
,
string
>
>
params
=
{{
"startTime"
,
to_string
(
tss
)},{
"endTime"
,
to_string
(
tse
)},{
"cameraId"
,
ipcSn
},
{
"headOffset"
,
to_string
(
offsetS
)},{
"tailOffset"
,
to_string
(
offsetE
)}};
json
params
;
vector
<
string
>
fileNames
;
params
[
"startTime"
]
=
to_string
(
tss
);
params
[
"endTime"
]
=
to_string
(
tse
);
params
[
"cameraId"
]
=
ipcSn
;
params
[
"headOffset"
]
=
to_string
(
offsetS
);
params
[
"tailOffset"
]
=
to_string
(
offsetE
);
json
fileNames
;
string
sf
;
string
sf
;
for
(
auto
&
i
:
v
)
{
for
(
auto
&
i
:
v
)
{
string
fname
=
this
->
urlOut
+
"/"
+
i
+
".mp4"
;
string
fname
=
this
->
urlOut
+
"/"
+
i
+
".mp4"
;
...
@@ -975,16 +980,20 @@ public:
...
@@ -975,16 +980,20 @@ public:
spdlog
::
info
(
"evslicer {} file upload range:({},{}) = ({}, {}), url: {}"
,
selfId
,
tss
,
tse
,
this
->
videoFileTs2Name
(
tss
),
this
->
videoFileTs2Name
(
tse
),
this
->
videoFileServerApi
);
spdlog
::
info
(
"evslicer {} file upload range:({},{}) = ({}, {}), url: {}"
,
selfId
,
tss
,
tse
,
this
->
videoFileTs2Name
(
tss
),
this
->
videoFileTs2Name
(
tse
),
this
->
videoFileServerApi
);
string
strResp
;
string
strResp
;
ret
=
netutils
::
postFiles
(
std
::
move
(
this
->
videoFileServerApi
),
std
::
move
(
params
),
std
::
move
(
fileNames
)
,
strResp
);
ret
=
netutils
::
postFiles
(
this
->
videoFileServerApi
,
params
,
fileNames
,
strResp
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
spdlog
::
info
(
"evslicer {} failed uploaded ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
spdlog
::
info
(
"evslicer {} failed uploaded ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
jEvt
[
"cnt"
]
=
ret
;
jEvt
[
"cnt"
]
=
ret
;
}
else
{
}
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
this
->
selfId
,
evt
);
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
selfId
,
evt
);
// move to failed folder
system
(
string
(
"mkdir -p /var/data/evsuits/failed_events/"
).
c_str
());
}
else
{
}
else
{
spdlog
::
info
(
"evslicer {} retrying upload"
,
selfId
);
jEvt
[
"cnt"
]
=
jEvt
[
"cnt"
].
get
<
int
>
()
-
1
;
jEvt
[
"cnt"
]
=
jEvt
[
"cnt"
].
get
<
int
>
()
-
1
;
lock_guard
<
mutex
>
lock
(
this
->
mutEvent
);
lock_guard
<
mutex
>
lock
(
this
->
mutEvent
);
this
->
eventQueue
.
push
(
jEvt
.
dump
());
this
->
eventQueue
.
push
(
jEvt
.
dump
());
...
@@ -995,7 +1004,6 @@ public:
...
@@ -995,7 +1004,6 @@ public:
}
}
}
}
}
}
}
else
{
else
{
spdlog
::
info
(
"evslicer {} upload ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
spdlog
::
info
(
"evslicer {} upload ({}, {}). local({}, {}). resp: {} files:
\n
{}"
,
selfId
,
tss
,
tse
,
first
,
end
,
strResp
,
sf
);
if
(
ret
>
0
){
if
(
ret
>
0
){
...
@@ -1006,7 +1014,7 @@ public:
...
@@ -1006,7 +1014,7 @@ public:
if
(
resp
.
count
(
"code"
)
!=
0
&&
resp
[
"code"
]
!=
0
)
{
if
(
resp
.
count
(
"code"
)
!=
0
&&
resp
[
"code"
]
!=
0
)
{
if
(
resp
[
"code"
]
==
4
||
resp
[
"code"
]
==
7
)
{
if
(
resp
[
"code"
]
==
4
||
resp
[
"code"
]
==
7
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
if
(
jEvt
.
count
(
"cnt"
)
==
0
)
{
jEvt
[
"cnt"
]
=
10
;
jEvt
[
"cnt"
]
=
2
;
}
else
{
}
else
{
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
if
(
jEvt
[
"cnt"
].
get
<
int
>
()
<=
0
)
{
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
this
->
selfId
,
evt
);
spdlog
::
error
(
"evslicer {} failed to upload videos over N times, abort retrying: {}"
,
this
->
selfId
,
evt
);
...
...
opencv-motion-detect/postfile.cpp
浏览文件 @
0c5338a4
...
@@ -17,7 +17,7 @@ static size_t WriteCallback(char *contents, size_t size, size_t nmemb, void *use
...
@@ -17,7 +17,7 @@ static size_t WriteCallback(char *contents, size_t size, size_t nmemb, void *use
return
size
*
nmemb
;
return
size
*
nmemb
;
}
}
int
postFiles
(
string
&
&
url
,
vector
<
tuple
<
string
,
string
>
>
&&
params
,
vector
<
string
>
&
&
fileNames
,
string
&
response
){
int
postFiles
(
string
&
url
,
json
&
params
,
json
&
fileNames
,
string
&
response
){
CURL
*
curl
;
CURL
*
curl
;
CURLcode
res
;
CURLcode
res
;
curl_mime
*
form
=
NULL
;
curl_mime
*
form
=
NULL
;
...
@@ -38,14 +38,14 @@ int postFiles(string &&url, vector<tuple<string, string> > &¶ms, vector<stri
...
@@ -38,14 +38,14 @@ int postFiles(string &&url, vector<tuple<string, string> > &¶ms, vector<stri
for
(
auto
&
f
:
fileNames
)
{
for
(
auto
&
f
:
fileNames
)
{
field
=
curl_mime_addpart
(
form
);
field
=
curl_mime_addpart
(
form
);
curl_mime_name
(
field
,
"files[]"
);
curl_mime_name
(
field
,
"files[]"
);
curl_mime_filedata
(
field
,
f
.
c_str
());
curl_mime_filedata
(
field
,
string
(
f
)
.
c_str
());
spdlog
::
debug
(
"curl file: {}"
,
f
);
spdlog
::
debug
(
"curl file: {}"
,
string
(
f
)
);
}
}
string
queryString
;
string
queryString
;
int
cnt
=
0
;
int
cnt
=
0
;
for
(
auto
&
[
k
,
v
]
:
params
)
{
for
(
auto
&
[
k
,
v
]
:
params
.
items
()
)
{
queryString
+=
(
cnt
==
0
?
string
(
""
)
:
string
(
"&"
))
+
k
+
"="
+
v
;
queryString
+=
(
cnt
==
0
?
string
(
""
)
:
string
(
"&"
))
+
string
(
k
)
+
"="
+
string
(
v
)
;
cnt
++
;
cnt
++
;
}
}
...
@@ -63,9 +63,10 @@ int postFiles(string &&url, vector<tuple<string, string> > &¶ms, vector<stri
...
@@ -63,9 +63,10 @@ int postFiles(string &&url, vector<tuple<string, string> > &¶ms, vector<stri
res
=
curl_easy_perform
(
curl
);
res
=
curl_easy_perform
(
curl
);
/* Check for errors */
/* Check for errors */
if
(
res
!=
CURLE_OK
){
if
(
res
!=
CURLE_OK
){
spdlog
::
error
(
"failed to upload files: {}
"
,
curl_easy_strerror
(
res
));
spdlog
::
error
(
"failed to upload files: {}
- {}"
,
res
,
curl_easy_strerror
(
res
));
switch
(
res
){
switch
(
res
){
case
CURLE_READ_ERROR
:
case
CURLE_READ_ERROR
:
case
CURLE_RECV_ERROR
:
case
CURLE_UPLOAD_FAILED
:
case
CURLE_UPLOAD_FAILED
:
case
CURLE_OPERATION_TIMEDOUT
:
case
CURLE_OPERATION_TIMEDOUT
:
case
CURLE_SEND_ERROR
:
case
CURLE_SEND_ERROR
:
...
...
opencv-motion-detect/postfile.h
浏览文件 @
0c5338a4
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
#include <string>
#include <string>
#include <curl/curl.h>
#include <curl/curl.h>
#include <tuple>
#include <vector>
#include "inc/spdlog/spdlog.h"
#include "inc/spdlog/spdlog.h"
#include "inc/json.hpp"
namespace
netutils
{
namespace
netutils
{
using
namespace
std
;
using
namespace
std
;
int
postFiles
(
string
&&
url
,
vector
<
tuple
<
string
,
string
>
>
&&
params
,
vector
<
string
>
&&
fileNames
,
string
&
resp
);
using
namespace
nlohmann
;
int
postFiles
(
string
&
url
,
json
&
params
,
json
&
fileNames
,
string
&
resp
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论