From 9e5babf9db52e64bdae60137be7696e56241fca6 Mon Sep 17 00:00:00 2001
From: xingzilong <xingzilong@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 18 八月 2017 18:12:17 +0800
Subject: [PATCH] H264 NALU解析  并在RTSPServer判断

---
 VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp |   86 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
index 5bc9c0d..ad5210f 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFuncClient.cpp
@@ -5,22 +5,78 @@
 #include "RemoteFuncClient.h"
 #include "RemoteFunc.h"
 #include "RtspNativeCodecJNIClient.h"
-RemoteServer<RtspFaceDetectImpl> remoteServer("127.0.0.1",8111);
-void startRemoteServer(){
-    remoteServer.start();
+#include "AppConfig.h"
+
+#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()
+{
+	remoteServer.start();
 }
-RtspFaceViewClient rtspFaceViewClient;
-RtspFaceViewClient& RtspFaceViewClient(){
-    return rtspFaceViewClient;
+
+RtspFaceViewClient * getRtspFaceViewClient()
+{
+    if(rtspFaceViewClient == nullptr)
+        rtspFaceViewClient = new RtspFaceViewClient;
+	return rtspFaceViewClient;
 }
-RtspFaceViewClient::RtspFaceViewClient():rpcClient("127.0.0.1",8112),
-                                         RtspFaceView::Client(rpcClient.getMain<RtspFaceView>())
+
+RtspFaceViewClient::RtspFaceViewClient() :
+        rpcClient(nullptr)
 {}
-::kj::WaitScope& RtspFaceViewClient::getWaitScope(){
-    return rpcClient.getWaitScope();
+
+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::Promise<void> RtspFaceDetectImpl::fireFaceCountListener(FireFaceCountListenerContext context) {
-    auto results = context.getResults();
-    remoteFireFaceCountListener(context.getParams(), results);
-    context.setResults(results);
-}
\ No newline at end of file
+
+::kj::WaitScope &RtspFaceViewClient::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);
+    return kj::READY_NOW;
+}

--
Gitblit v1.8.0