pans
2017-08-18 5cf652629fb40796cd2e0ab17c3617ed52365473
VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
@@ -5,8 +5,15 @@
#include "RemoteFuncClient.h"
#include "RemoteFunc.h"
#include "RtspNativeCodecJNIClient.h"
#include "AppConfig.h"
RemoteServer<RtspFaceDetectImpl> remoteServer("127.0.0.1", 8111);
#include <string>
#include <iostream>
using namespace std;
AppConfig config("data/config.cfg");
RemoteServer<RtspFaceDetectImpl> remoteServer(config.getStringValue("local_ip"), config.getIntValue("local_port"));
//RemoteServer<RtspFaceDetectImpl> remoteServer("192.168.1.97", 8111);
static RtspFaceViewClient* rtspFaceViewClient = nullptr;
void startRemoteServer()
@@ -14,36 +21,62 @@
   remoteServer.start();
}
RtspFaceViewClient* getRtspFaceViewClient()
RtspFaceViewClient * getRtspFaceViewClient()
{
   if (rtspFaceViewClient != nullptr)
   {
      try
      {
         rtspFaceViewClient = new RtspFaceViewClient;
      }
      catch(...)
      {
         delete rtspFaceViewClient;
         rtspFaceViewClient = nullptr;
         LOG_ERROR << "aaaaaaaa"<<LOG_ENDL;//#todo
      }
   }
    if(rtspFaceViewClient == nullptr)
        rtspFaceViewClient = new RtspFaceViewClient;
   return rtspFaceViewClient;
}
RtspFaceViewClient::RtspFaceViewClient() :
      rpcClient("127.0.0.1", 8112), RtspFaceView::Client(rpcClient.getMain<RtspFaceView>())
        rpcClient(nullptr)
{}
RtspFaceView::Client& RtspFaceViewClient::getClient()
{
    if (client == nullptr) {
        try
        {
            client = new RtspFaceView::Client(getEzRpcClient()->getMain<RtspFaceView>());
        }
        catch (const kj::Exception& e)
        {
            delete client;
            client = nullptr;
            throw e;
        }
    }
    return *client;
}
::kj::WaitScope &RtspFaceViewClient::getWaitScope()
{
   return rpcClient.getWaitScope();
    return getEzRpcClient()->getWaitScope();
}
capnp::EzRpcClient * RtspFaceViewClient::getEzRpcClient()
{
    if (rpcClient == nullptr) {
        try
        {
            //rpcClient = new capnp::EzRpcClient("192.168.1.116", 8112);
            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> RtspFaceDetectImpl::fireFaceCountListener(FireFaceCountListenerContext context)
{
   auto results = context.getResults();
    LOG_ERROR << "!!!!!!!!!!!!!!!!!!!!!WHO  find face!!!!!!!" << LOG_ENDL;
   remoteFireFaceCountListener(context.getParams(), results);
   context.setResults(results);
    //context.setResults(results);
    return kj::READY_NOW;
}