| | |
| | | // Created by pansen on 2017/8/4. |
| | | // |
| | | #include "AppConfig.h" |
| | | #include "RemoteFunc.h" |
| | | #include "RemoteFuncServer.h" |
| | | #include "RemoteFunc.h" |
| | | #include "RtspNativeCodecJNIServer.h" |
| | | RemoteServer<RtspFaceViewImpl> remoteServer("127.0.0.1",8112); |
| | | RtspFaceDetectClient rtspFaceDetectClient; |
| | | void startRemoteServer(){ |
| | | AppConfig config; |
| | | config.loadConfig("data/config.cfg"); |
| | | |
| | | #include <string> |
| | | #include <iostream> |
| | | using namespace std; |
| | | |
| | | AppConfig config("data/config.cfg"); |
| | | RemoteServer<RtspFaceViewImpl> remoteServer(config.getStringValue("local_ip"), config.getIntValue("local_port")); |
| | | //RemoteServer<RtspFaceViewImpl> remoteServer("192.168.1.97", 8112); |
| | | static RtspFaceDetectClient* rtspFaceDetectClient = nullptr; |
| | | |
| | | void startRemoteServer() |
| | | { |
| | | remoteServer.start(); |
| | | } |
| | | RtspFaceDetectClient& getRtspFaceDetectClient(){ |
| | | return rtspFaceDetectClient; |
| | | } |
| | | //#todo |
| | | RtspFaceDetectClient::RtspFaceDetectClient():rpcClient("127.0.0.1",8111), |
| | | RtspFaceDetect::Client(rpcClient.getMain<RtspFaceDetect>()) |
| | | {} |
| | | ::kj::WaitScope& RtspFaceDetectClient::getWaitScope() { |
| | | return rpcClient.getWaitScope(); |
| | | |
| | | RtspFaceDetectClient * getRtspFaceDetectClient() |
| | | { |
| | | if(rtspFaceDetectClient == nullptr) |
| | | rtspFaceDetectClient = new RtspFaceDetectClient; |
| | | return rtspFaceDetectClient; |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::getFaceList(GetFaceListContext context) { |
| | | auto results = context.getResults(); |
| | | remoteGetFaceList(context.getParams(), results); |
| | | context.setResults(results); |
| | | //#todo 构造函数修改 |
| | | RtspFaceDetectClient::RtspFaceDetectClient() : |
| | | rpcClient(nullptr) |
| | | { |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::getFaceImages(GetFaceImagesContext context){ |
| | | auto results = context.getResults(); |
| | | remoteGetFaceListImage(context.getParams(), results); |
| | | context.setResults(results); |
| | | RtspFaceDetect::Client* RtspFaceDetectClient::getClient() |
| | | { |
| | | LOG_INFO << "new client @ " << (int*)client << LOG_ENDL; |
| | | |
| | | if (client == nullptr) { |
| | | LOG_INFO << "new client 2" << LOG_ENDL; |
| | | try |
| | | { |
| | | client = new RtspFaceDetect::Client(getEzRpcClient()->getMain<RtspFaceDetect>()); |
| | | } |
| | | catch (const kj::Exception& e) |
| | | { |
| | | LOG_ERROR << "new client error" << LOG_ENDL; |
| | | delete client; |
| | | client = nullptr; |
| | | throw e; |
| | | } |
| | | } |
| | | return client; |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::setFaceLabel(SetFaceLabelContext context) { |
| | | ::kj::WaitScope &RtspFaceDetectClient::getWaitScope() |
| | | { |
| | | return getEzRpcClient()->getWaitScope(); |
| | | } |
| | | |
| | | capnp::EzRpcClient * RtspFaceDetectClient::getEzRpcClient() |
| | | { |
| | | if (rpcClient == nullptr) { |
| | | try |
| | | { |
| | | // rpcClient = new capnp::EzRpcClient("192.168.1.97", 8111); |
| | | rpcClient = new capnp::EzRpcClient(config.getStringValue("server_ip"), config.getIntValue("server_port")); |
| | | } |
| | | catch (const kj::Exception& e) |
| | | { |
| | | delete rpcClient; |
| | | rpcClient = nullptr; |
| | | throw e; |
| | | } |
| | | } |
| | | return rpcClient; |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::getFaceList(GetFaceListContext context) |
| | | { |
| | | LOG_ERROR <<"getFaceList :start !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<< LOG_ENDL; |
| | | auto results = context.getResults(); |
| | | remoteGetFaceList(context.getParams(), results); |
| | | |
| | | return kj::READY_NOW; |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::getFaceImages(GetFaceImagesContext context) |
| | | { |
| | | auto results = context.getResults(); |
| | | remoteGetFaceListImage(context.getParams(), results); |
| | | LOG_ERROR <<"getFaceImages : !!!!!!!!!!!!!!"<< LOG_ENDL; |
| | | return kj::READY_NOW; |
| | | } |
| | | |
| | | ::kj::Promise<void> RtspFaceViewImpl::setFaceLabel(SetFaceLabelContext context) |
| | | { |
| | | LOG_ERROR <<"setFaceLabel : !!!!!!!!!!!!"<< LOG_ENDL; |
| | | auto results = context.getResults(); |
| | | |
| | | remoteSetFaceLabel(context.getParams(), results); |
| | | context.setResults(results); |
| | | |
| | | return kj::READY_NOW; |
| | | } |