提交 3bbee587 authored 作者: blu's avatar blu

init

上级 47edd465
......@@ -54,7 +54,7 @@ namespace LVDB {
}
Status s = DB::Open(options, fileName, &pdb);
if(!s.ok() && s.) {
if(!s.ok()) {
spdlog::error("failed to open db {}: {}", fileName, s.ToString());
}
......
......@@ -108,7 +108,6 @@ private:
exit(1);
}
selfId = devSn + ":evmlmotion:" + to_string(iid);
while(!inited) {
// TODO: req config
bool found = false;
......@@ -126,8 +125,9 @@ private:
for(auto &j: ipcs) {
json mls = j["modules"]["evml"];
for(auto &p:mls) {
if(p["sn"] == devSn && p["iid"] == iid && p["type"] == "motion") {
if(p["sn"] == devSn && p["status"] == 0 && p["type"] == "motion") {
evmlmotion = p;
iid = p["iid"];
break;
}
}
......@@ -144,11 +144,13 @@ private:
}
if(!found) {
spdlog::error("evmlmotion {} {}: no valid config found. retrying load config...", devSn, iid);
spdlog::error("evmlmotion {}: no valid config found. retrying load config...", devSn);
this_thread::sleep_for(chrono::seconds(3));
continue;
}
selfId = devSn + ":evmlmotion:" + to_string(iid);
// TODO: currently just take the first puller, but should test connectivity
json evpuller = ipc["modules"]["evpuller"][0];
pullerGid = evpuller["sn"].get<string>() + ":evpuller:" + to_string(evpuller["iid"]);
......@@ -156,11 +158,11 @@ private:
urlPub = string("tcp://") + evpuller["addr"].get<string>() + ":" + to_string(evpuller["port-pub"]);
urlRouter = string("tcp://") + evmgr["addr"].get<string>() + ":" + to_string(evmgr["port-router"]);
spdlog::info("evmlmotion {} {} will connect to {} for sub, {} for router", devSn, iid, urlPub, urlRouter);
spdlog::info("evmlmotion {} will connect to {} for sub, {} for router", selfId, urlPub, urlRouter);
// TODO: multiple protocols support
if(evmlmotion.count("path") == 0) {
spdlog::warn("evslicer {} {} no params for path, using default: {}", devSn, iid, URLOUT_DEFAULT);
spdlog::warn("evslicer {} {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT;
}
else {
......@@ -174,7 +176,7 @@ private:
}
}
catch(exception &e) {
spdlog::error("evmlmotion {} {} exception in EvPuller.init {:s} retrying", devSn, iid, e.what());
spdlog::error("evmlmotion {} exception in EvPuller.init {:s} retrying", selfId, e.what());
this_thread::sleep_for(chrono::seconds(3));
continue;
}
......@@ -197,11 +199,11 @@ private:
ret = z_send_multiple(pDealer, body);
if(ret < 0) {
spdlog::error("evmlmotion {} {} failed to send multiple: {}", devSn, iid, zmq_strerror(zmq_errno()));
spdlog::error("evmlmotion {} failed to send multiple: {}", selfId, zmq_strerror(zmq_errno()));
//TODO:
}
else {
spdlog::info("evmlmotion {} {} sent hello to router: {}", devSn, iid, mgrSn);
spdlog::info("evmlmotion {} sent hello to router: {}", selfId, mgrSn);
}
return ret;
......@@ -216,32 +218,32 @@ private:
pSub = zmq_socket(pSubCtx, ZMQ_SUB);
ret = zmq_setsockopt(pSub, ZMQ_SUBSCRIBE, "", 0);
if(ret != 0) {
spdlog::error("evmlmotion {} {} failed set setsockopt: {}", devSn, iid, urlPub);
spdlog::error("evmlmotion {} failed set setsockopt: {}", selfId, urlPub);
return -1;
}
ret = zmq_connect(pSub, urlPub.c_str());
if(ret != 0) {
spdlog::error("evmlmotion {} {} failed connect pub: {}", devSn, iid, urlPub);
spdlog::error("evmlmotion {} failed connect pub: {}", selfId, urlPub);
return -2;
}
// setup dealer
pDealerCtx = zmq_ctx_new();
pDealer = zmq_socket(pDealerCtx, ZMQ_DEALER);
spdlog::info("evmlmotion {} {} try create req to {}", devSn, iid, urlRouter);
spdlog::info("evmlmotion {} try create req to {}", selfId, urlRouter);
ret = zmq_setsockopt(pDealer, ZMQ_IDENTITY, selfId.c_str(), selfId.size());
ret += zmq_setsockopt (pDealer, ZMQ_ROUTING_ID, selfId.c_str(), selfId.size());
if(ret < 0) {
spdlog::error("evpusher {} {} failed setsockopts router: {}", devSn, iid, urlRouter);
spdlog::error("evpusher {} {} failed setsockopts router: {}", selfId, urlRouter);
return -3;
}
if(ret < 0) {
spdlog::error("evmlmotion {} {} failed setsockopts router: {}", devSn, iid, urlRouter);
spdlog::error("evmlmotion {} failed setsockopts router: {}", selfId, urlRouter);
return -3;
}
ret = zmq_connect(pDealer, urlRouter.c_str());
if(ret != 0) {
spdlog::error("evmlmotion {} {} failed connect dealer: {}", devSn, iid, urlRouter);
spdlog::error("evmlmotion {} failed connect dealer: {}", selfId, urlRouter);
return -4;
}
//ping
......@@ -264,7 +266,7 @@ private:
int ret = 0;
// req avformatcontext packet
// send hello to puller
spdlog::info("evmlmotion {} {} send hello to puller: {}", devSn, iid, pullerGid);
spdlog::info("evmlmotion {} send hello to puller: {}", selfId, pullerGid);
vector<vector<uint8_t> > body;
body.push_back(str2body(pullerGid));
json meta;
......@@ -276,7 +278,7 @@ private:
while(!gotFormat) {
ret = z_send_multiple(pDealer, body);
if(ret < 0) {
spdlog::error("evmlmotion {} {}, failed to send hello to puller: {}", devSn, iid, zmq_strerror(zmq_errno()));
spdlog::error("evmlmotion {}, failed to send hello to puller: {}", selfId, zmq_strerror(zmq_errno()));
continue;
}
......@@ -286,18 +288,18 @@ private:
ret = zmq_errno();
if(ret != 0) {
if(failedCnt % 100 == 0) {
spdlog::error("evmlmotion {} {}, error receive avformatctx: {}, {}", devSn, iid, v.size(), zmq_strerror(ret));
spdlog::info("evmlmotion {} {} retry connect to peers", devSn, iid);
spdlog::error("evmlmotion {}, error receive avformatctx: {}, {}", selfId, v.size(), zmq_strerror(ret));
spdlog::info("evmlmotion {} retry connect to peers", selfId);
}
this_thread::sleep_for(chrono::seconds(5));
failedCnt++;
}
else {
spdlog::error("evmlmotion {} {}, received bad size zmq msg for avformatctx: {}", devSn, iid, v.size());
spdlog::error("evmlmotion {}, received bad size zmq msg for avformatctx: {}", selfId, v.size());
}
}
else if(body2str(v[0]) != pullerGid) {
spdlog::error("evmlmotion {} {}, invalid sender for avformatctx: {}, should be: {}", devSn, iid, body2str(v[0]), pullerGid);
spdlog::error("evmlmotion {}, invalid sender for avformatctx: {}, should be: {}", selfId, body2str(v[0]), pullerGid);
}
else {
try {
......@@ -309,7 +311,7 @@ private:
}
}
catch(exception &e) {
spdlog::error("evmlmotion {} {}, exception in parsing avformatctx packet: {}", devSn, iid, e.what());
spdlog::error("evmlmotion {}, exception in parsing avformatctx packet: {}", selfId, e.what());
}
}
}
......@@ -567,9 +569,9 @@ protected:
v[2] = str2body(evt);
this->evtQueue->pop();
ret = z_send_multiple(this->pDealer, v);
spdlog::info("evmlmotion {} {} send event: {}", this->devSn, this->iid, evt);
spdlog::info("evmlmotion {} send event: {}", this->devSn, this->iid, evt);
if(ret < 0) {
spdlog::error("evmlmotion {} {} failed to send event: {}, {}", this->devSn, this->iid, evt, zmq_strerror(zmq_errno()));
spdlog::error("evmlmotion {} failed to send event: {}, {}", this->devSn, this->iid, evt, zmq_strerror(zmq_errno()));
}
}
else {
......
......@@ -33,19 +33,11 @@ namespace fs = std::filesystem;
using namespace std;
using namespace zmqhelper;
int mqErrorMsg(string cls, string devSn, int iid, string extraInfo, int ret)
{
if(ret < 0) {
spdlog::error("{} {} {}, {}: {} ", cls, devSn, iid, extraInfo, zmq_strerror(zmq_errno()));
}
return ret;
}
class RepSrv: public TinyThread {
private:
string mgrSn;
string devSn;
string selfId;
int iid;
string urlRep;
const char * bytes;
......@@ -64,7 +56,7 @@ private:
ret = z_send_multiple(pDealer, body);
if(ret < 0) {
spdlog::error("evpuller {} {} failed to send multiple: {}", devSn, iid, zmq_strerror(zmq_errno()));
spdlog::error("evpuller {} failed to send multiple: {}", selfId, zmq_strerror(zmq_errno()));
}
return ret;
}
......@@ -81,19 +73,19 @@ private:
vector<vector<uint8_t> > rep = {v[0], v[1], msgBody};
ret = z_send_multiple(pDealer, rep);
if(ret < 0) {
spdlog::error("evpuller {} {} failed send rep to requester {}: {}", devSn, iid, body2str(v[0]), zmq_strerror(zmq_errno()));
spdlog::error("evpuller {} failed send rep to requester {}: {}", selfId, body2str(v[0]), zmq_strerror(zmq_errno()));
}
}
else if(meta["type"].get<string>() == EV_MSG_META_EVENT) {
// event msg
spdlog::info("evpuller {} {} received event: {}", devSn, iid, body2str(v[2]));
spdlog::info("evpuller {} received event: {}", selfId, body2str(v[2]));
}
else {
spdlog::error("evpuller {} {} unknown meta from {}: {}", devSn, iid, body2str(v[0]), body2str(v[1]));
spdlog::error("evpuller {} unknown meta from {}: {}", selfId, body2str(v[0]), body2str(v[1]));
}
}
catch(exception &e) {
spdlog::error("evpuller {} {} excpetion parse request from {}: {}", devSn, iid, body2str(v[0]), body2str(v[1]));
spdlog::error("evpuller {} excpetion parse request from {}: {}", selfId, body2str(v[0]), body2str(v[1]));
}
return ret;
......@@ -128,7 +120,7 @@ protected:
auto v = z_recv_multiple(pDealer, false);
if(v.size() != 3) {
//TODO:
spdlog::error("evpuller {} {}, repSrv received invalid message: {}", devSn, iid, v.size());
spdlog::error("evpuller {}, repSrv received invalid message: {}", selfId, v.size());
continue;
}
handleMsg(v);
......@@ -140,7 +132,9 @@ public:
RepSrv(RepSrv&&) = delete;
RepSrv(string mgrSn, string devSn, int iid, const char* formatBytes,
int len, void *pDealer):mgrSn(mgrSn),devSn(devSn), iid(iid), bytes(formatBytes),
len(len), pDealer(pDealer) {};
len(len), pDealer(pDealer) {
selfId = devSn+":evpuller:" + to_string(iid);
};
~RepSrv() {};
};
......@@ -171,7 +165,7 @@ private:
tsLastBoot = info["lastboot"];
tsUpdateTime=info["updatetime"];
spdlog::info("evmgr info: sn = {}, lastboot = {}, updatetime = {}", info["sn"].get<string>(), ctime(&tsLastBoot), ctime(&tsUpdateTime));
spdlog::info("evpuller info: sn = {}, lastboot = {}, updatetime = {}", info["sn"].get<string>(), ctime(&tsLastBoot), ctime(&tsUpdateTime));
devSn = info["sn"];
ret = LVDB::getLocalConfig(config);
......@@ -180,7 +174,6 @@ private:
exit(1);
}
selfId = devSn+":evpuller:" + to_string(iid);
while(!inited) {
// TODO: req config
bool found = false;
......@@ -200,8 +193,9 @@ private:
for(auto &j: ipcs) {
json pullers = j["modules"]["evpuller"];
for(auto &p:pullers) {
if(p["sn"] == devSn && p["iid"] == iid) {
if(p["sn"] == devSn && p["status"] == 0) {
evpuller = p;
iid = p["iid"];
break;
}
}
......@@ -217,48 +211,55 @@ private:
}
if(!found) {
spdlog::error("evpuller {} {} no valid config found. retrying load config...", devSn, iid);
spdlog::error("evpuller {} no valid config found", devSn);
goto togo_sleep_continue;
}
selfId = devSn+":evpuller:" + to_string(iid);
mgrSn = evmgr["sn"];
user = ipc["user"];
passwd = ipc["password"];
urlIn = "rtsp://" + user + ":" + passwd + "@" + ipc["addr"].get<string>() + "/h264/ch1/sub/av_stream";
addr = evpuller["addr"].get<string>();
if(addr == "*" || addr == "0.0.0.0") {
spdlog::error("evpuller {} {} invalid addr {} for pub", devSn, iid, evpuller.dump());
spdlog::error("evpuller {} invalid addr {} for pub", selfId, evpuller.dump());
goto togo_sleep_continue;
}
urlPub = string("tcp://*:") + to_string(evpuller["port-pub"]);
// urlRep = string("tcp://") +data["addr"].get<string>() + ":" + to_string(data["port-rep"]);
urlDealer = "tcp://" + evmgr["addr"].get<string>() + string(":") + to_string(evmgr["port-router"]);
spdlog::info("evpuller {} {} bind on {} for pub, connect to {} for dealer", devSn, iid, urlPub, urlDealer);
spdlog::info("evpuller {} bind on {} for pub, connect to {} for dealer", selfId, urlPub, urlDealer);
pPubCtx = zmq_ctx_new();
pPub = zmq_socket(pPubCtx, ZMQ_PUB);
ret = mqErrorMsg("evpuller", devSn, iid, "failed to bind zmq", zmq_bind(pPub, urlPub.c_str()));
ret = zmq_bind(pPub, urlPub.c_str());
if(ret < 0) {
spdlog::error("evpuller {} failed to bind to {}", selfId, urlPub);
goto togo_sleep_continue;
}
pDealerCtx = zmq_ctx_new();
pDealer = zmq_socket(pDealerCtx, ZMQ_DEALER);
ret += mqErrorMsg("evpuller", devSn, iid, "failed to set socksopt", zmq_setsockopt(pDealer, ZMQ_IDENTITY, selfId.c_str(), selfId.size()));
ret = zmq_setsockopt(pDealer, ZMQ_IDENTITY, selfId.c_str(), selfId.size());
if(ret < 0) {
spdlog::error("evpuller {} failed to set identity", selfId);
goto togo_sleep_continue;
}
ret += zmq_setsockopt (pDealer, ZMQ_ROUTING_ID, selfId.c_str(), selfId.size());
if(ret < 0) {
spdlog::error("evpusher {} {} failed setsockopts router: {}", devSn, iid, urlDealer);
spdlog::error("evpusher {} {} failed setsockopts router: {}", selfId, urlDealer);
goto togo_sleep_continue;
}
ret += mqErrorMsg("evpuller", devSn, iid, "failed to connect to router " + urlDealer, zmq_connect(pDealer, urlDealer.c_str()));
ret = zmq_connect(pDealer, urlDealer.c_str());
if(ret < 0) {
spdlog::error("evpuller {} {} zmq setup failed. retrying load config...", devSn, iid);
spdlog::error("evpuller {} failed to connect to router {}", selfId, urlDealer);
goto togo_sleep_continue;
}
}
catch(exception &e) {
this_thread::sleep_for(chrono::seconds(3));
spdlog::error("evpuller {} {} exception in EvPuller.init {:s}, retrying... ",devSn, iid, e.what());
spdlog::error("evpuller {} exception in EvPuller.init {:s}, retrying... ", selfId, e.what());
continue;
}
......
......@@ -80,9 +80,7 @@ private:
spdlog::error("failed to get local configuration");
exit(1);
}
selfId = devSn + ":evslicer:" + to_string(iid);
// TODO: read local slices list and last index
while(!inited) {
// TODO: req config
bool found = false;
......@@ -100,8 +98,9 @@ private:
for(auto &j: ipcs) {
json pullers = j["modules"]["evslicer"];
for(auto &p:pullers) {
if(p["sn"] == devSn && p["iid"] == iid) {
if(p["sn"] == devSn && p["status"] ==0) {
evslicer = p;
iid = p["iid"];
break;
}
}
......@@ -118,23 +117,25 @@ private:
}
if(!found) {
spdlog::error("evslicer {} {}: no valid config found. retrying load config...", devSn, iid);
spdlog::error("evslicer {}: no valid config found. retrying load config...", devSn);
this_thread::sleep_for(chrono::seconds(3));
continue;
}
selfId = devSn + ":evslicer:" + to_string(iid);
json evpuller = ipc["modules"]["evpuller"][0];
pullerGid = evpuller["sn"].get<string>() + ":evpuller:" + to_string(evpuller["iid"]);
mgrSn = evmgr["sn"];
if(evslicer.count("path") == 0) {
spdlog::warn("evslicer {} {} no params for path, using default: {}", devSn, iid, URLOUT_DEFAULT);
spdlog::warn("evslicer {} no params for path, using default: {}", selfId, URLOUT_DEFAULT);
urlOut = URLOUT_DEFAULT;
}
else {
urlOut = evslicer["path"];
}
if(evslicer.count("days") == 0) {
spdlog::warn("evslicer {} {} no params for days, using default: {}", devSn, iid, NUM_DAYS_DEFAULT);
spdlog::warn("evslicer {} no params for days, using default: {}", selfId, NUM_DAYS_DEFAULT);
days = NUM_DAYS_DEFAULT;
}
else {
......@@ -142,7 +143,7 @@ private:
}
if(evslicer.count("minutes") == 0) {
spdlog::warn("evslicer {} {} no params for minutes, using default: {}", devSn, iid, MINUTES_PER_SLICE_DEFAULT);
spdlog::warn("evslicer {} no params for minutes, using default: {}", selfId, MINUTES_PER_SLICE_DEFAULT);
minutes = MINUTES_PER_SLICE_DEFAULT;
}
else {
......@@ -163,10 +164,10 @@ private:
urlPub = string("tcp://") + evpuller["addr"].get<string>() + ":" + to_string(evpuller["port-pub"]);
urlRouter = string("tcp://") + evmgr["addr"].get<string>() + ":" + to_string(evmgr["port-router"]);
spdlog::info("evslicer {} {} will connect to {} for sub, {} for router", devSn, iid, urlPub, urlRouter);
spdlog::info("evslicer {} will connect to {} for sub, {} for router", selfId, urlPub, urlRouter);
}
catch(exception &e) {
spdlog::error("evslicer {} {} exception in init {:s} retrying", devSn, iid, e.what());
spdlog::error("evslicer {} exception in init {:s} retrying", selfId, e.what());
this_thread::sleep_for(chrono::seconds(3));
continue;
}
......@@ -189,11 +190,11 @@ private:
ret = z_send_multiple(pDealer, body);
if(ret < 0) {
spdlog::error("evslicer {} {} failed to send multiple: {}", devSn, iid, zmq_strerror(zmq_errno()));
spdlog::error("evslicer {} failed to send multiple: {}", selfId, zmq_strerror(zmq_errno()));
//TODO:
}
else {
spdlog::info("evslicer {} {} sent hello to router: {}", devSn, iid, mgrSn);
spdlog::info("evslicer {} sent hello to router: {}", selfId, mgrSn);
}
return ret;
......@@ -208,32 +209,32 @@ private:
pSub = zmq_socket(pSubCtx, ZMQ_SUB);
ret = zmq_setsockopt(pSub, ZMQ_SUBSCRIBE, "", 0);
if(ret != 0) {
spdlog::error("evslicer {} {} failed set setsockopt: {}", devSn, iid, urlPub);
spdlog::error("evslicer {} failed set setsockopt: {}", selfId, urlPub);
return -1;
}
ret = zmq_connect(pSub, urlPub.c_str());
if(ret != 0) {
spdlog::error("evslicer {} {} failed connect pub: {}", devSn, iid, urlPub);
spdlog::error("evslicer {} failed connect pub: {}", selfId, urlPub);
return -2;
}
// setup dealer
pDealerCtx = zmq_ctx_new();
pDealer = zmq_socket(pDealerCtx, ZMQ_DEALER);
spdlog::info("evslicer {} {} try create req to {}", devSn, iid, urlRouter);
spdlog::info("evslicer {} try create req to {}", selfId, urlRouter);
ret = zmq_setsockopt(pDealer, ZMQ_IDENTITY, selfId.c_str(), selfId.size());
ret += zmq_setsockopt (pDealer, ZMQ_ROUTING_ID, selfId.c_str(), selfId.size());
if(ret < 0) {
spdlog::error("evpusher {} {} failed setsockopts router: {}", devSn, iid, urlRouter);
spdlog::error("evpusher {} {} failed setsockopts router: {}", selfId, urlRouter);
return -3;
}
if(ret < 0) {
spdlog::error("evslicer {} {} failed setsockopts router: {}", devSn, iid, urlRouter);
spdlog::error("evslicer {} failed setsockopts router: {}", selfId, urlRouter);
return -3;
}
ret = zmq_connect(pDealer, urlRouter.c_str());
if(ret != 0) {
spdlog::error("evslicer {} {} failed connect dealer: {}", devSn, iid, urlRouter);
spdlog::error("evslicer {} failed connect dealer: {}", selfId, urlRouter);
return -4;
}
//ping
......@@ -256,7 +257,7 @@ private:
int ret = 0;
// req avformatcontext packet
// send hello to puller
spdlog::info("evslicer {} {} send hello to puller: {}", devSn, iid, pullerGid);
spdlog::info("evslicer {} send hello to puller: {}", selfId, pullerGid);
vector<vector<uint8_t> > body;
body.push_back(str2body(pullerGid));
json meta;
......@@ -268,7 +269,7 @@ private:
while(!gotFormat) {
ret = z_send_multiple(pDealer, body);
if(ret < 0) {
spdlog::error("evslicer {} {}, failed to send hello to puller: {}", devSn, iid, zmq_strerror(zmq_errno()));
spdlog::error("evslicer {}, failed to send hello to puller: {}", selfId, zmq_strerror(zmq_errno()));
continue;
}
......@@ -278,18 +279,18 @@ private:
ret = zmq_errno();
if(ret != 0) {
if(failedCnt % 100 == 0) {
spdlog::error("evslicer {} {}, error receive avformatctx: {}, {}", devSn, iid, v.size(), zmq_strerror(ret));
spdlog::info("evslicer {} {} retry connect to peers", devSn, iid);
spdlog::error("evslicer {}, error receive avformatctx: {}, {}", selfId, v.size(), zmq_strerror(ret));
spdlog::info("evslicer {} retry connect to peers", selfId);
}
this_thread::sleep_for(chrono::seconds(5));
failedCnt++;
}
else {
spdlog::error("evslicer {} {}, received bad size zmq msg for avformatctx: {}", devSn, iid, v.size());
spdlog::error("evslicer {}, received bad size zmq msg for avformatctx: {}", selfId, v.size());
}
}
else if(body2str(v[0]) != pullerGid) {
spdlog::error("evslicer {} {}, invalid sender for avformatctx: {}, should be: {}", devSn, iid, body2str(v[0]), pullerGid);
spdlog::error("evslicer {}, invalid sender for avformatctx: {}, should be: {}", selfId, body2str(v[0]), pullerGid);
}
else {
try {
......@@ -301,7 +302,7 @@ private:
}
}
catch(exception &e) {
spdlog::error("evslicer {} {}, exception in parsing avformatctx packet: {}", devSn, iid, e.what());
spdlog::error("evslicer {}, exception in parsing avformatctx packet: {}", selfId, e.what());
}
}
}
......@@ -370,7 +371,7 @@ protected:
name = urlOut + "/" + name;
ret = avformat_alloc_output_context2(&pAVFormatRemux, NULL, "mp4", name.c_str());
if (ret < 0) {
spdlog::error("evslicer {} {} failed create avformatcontext for output: %s", devSn, iid, av_err2str(ret));
spdlog::error("evslicer {} failed create avformatcontext for output: %s", selfId, av_err2str(ret));
exit(1);
}
......@@ -379,12 +380,12 @@ protected:
if(streamList[i] != -1) {
out_stream = avformat_new_stream(pAVFormatRemux, NULL);
if (!out_stream) {
spdlog::error("evslicer {} {} failed allocating output stream 1", devSn, iid);
spdlog::error("evslicer {} failed allocating output stream 1", selfId);
ret = AVERROR_UNKNOWN;
}
ret = avcodec_parameters_copy(out_stream->codecpar, pAVFormatInput->streams[i]->codecpar);
if (ret < 0) {
spdlog::error("evslicer {} {} failed to copy codec parameters", devSn, iid);
spdlog::error("evslicer {} failed to copy codec parameters", selfId);
}
}
}
......@@ -393,13 +394,13 @@ protected:
if (!(pAVFormatRemux->oformat->flags & AVFMT_NOFILE)) {
ret = avio_open2(&pAVFormatRemux->pb, name.c_str(), AVIO_FLAG_WRITE, NULL, &pOptsRemux);
if (ret < 0) {
spdlog::error("evslicer {} {} could not open output file {}", devSn, iid, name);
spdlog::error("evslicer {} could not open output file {}", selfId, name);
}
}
ret = avformat_write_header(pAVFormatRemux, &pOptsRemux);
if (ret < 0) {
spdlog::error("evslicer {} {} error occurred when opening output file", devSn, iid);
spdlog::error("evslicer {} error occurred when opening output file", selfId);
}
// TODO:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论