From e473f9eeb0233afcbd38de5de975dea4d131026d Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 16 八月 2017 15:26:27 +0800
Subject: [PATCH] fix Remote client bug

---
 VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNIClient.cpp |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNIClient.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNIClient.cpp
index 474f89b..10ea530 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNIClient.cpp
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNIClient.cpp
@@ -39,17 +39,24 @@
 const size_t _faceImagesSize = MAX_FACE * MAX_FACE_WIDTH * MAX_FACE_HEIGHT * 3;
 uint8_t _faceImages[_faceImagesSize]; // android stack is small
 
+// #todo optimize not copy data here, set data to jbyteArray directly
+//Java_cn_com_basic_face_util_RtspFaceNative_getFaceList
+// Y channel of YUV420p, packed in protobuf
+static uint8_t buffer[MAX_FACE * MAX_FACE_WIDTH * MAX_FACE_HEIGHT] = {0};
+static size_t buffSize = sizeof(buffer);
+
 void remoteFireFaceCountListener(const RtspFaceDetect::FireFaceCountListenerParams::Reader& params, RtspFaceDetect::FireFaceCountListenerResults::Builder& results){
     int count = params.getFaceCount();
     int index = params.getCameraIndex();
-    g_CameraWrappers[index].fireFaceCount(count);
+    LOG_INFO <<count<< "+" << index<< LOG_ENDL;
+    g_CameraWrappers[index - 1].fireFaceCount(count);
 }
 extern "C"
 {
 
 void Java_cn_com_basic_face_util_RtspFaceNative_init(JNIEnv *env, jclass clazz)
 {
-    g_logger.set_level(INFO);
+    g_logger.set_level(VERBOSE);
 
     cpu_sched();
 
@@ -363,10 +370,7 @@
     cameraIdx -= 1;
     CameraWrapper &cameraWrapper(g_CameraWrappers[cameraIdx]);
 
-    // #todo optimize not copy data here, set data to jbyteArray directly
-    // Y channel of YUV420p, packed in protobuf
-    uint8_t buffer[MAX_FACE * MAX_FACE_WIDTH * MAX_FACE_HEIGHT] = {0};
-    size_t buffSize = sizeof(buffer);
+
 
     bool ret = false;
 
@@ -379,21 +383,24 @@
         LOG_ERROR <<"client : i want getFaceList!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<< LOG_ENDL;
         RtspFaceViewClient* client = getRtspFaceViewClient();
         RtspFaceView::Client rClient = client->getEzRpcClient()->getMain<RtspFaceView>();
+        //auto& waitScope =client->getEzRpcClient()->getWaitScope();
         auto& waitScope =client->getWaitScope();
-
         auto  request = rClient.getFaceListRequest();
         request.setCameraIndex(cameraIdx);
         auto sendAct = request.send();
-        auto  result =sendAct.wait(waitScope);
+        auto  result = sendAct.wait(waitScope);
         ret = result.getFaceList().size() > 0;
         LOG_DEBUG << "@@@ getFaceList get data" << LOG_ENDL;
-        memcpy(pBufPB,result.getFaceList().begin(),buffSize);
+        memcpy(pBufPB,result.getFaceList().begin(),result.getFaceList().size());
     }
-    catch (const kj::Exception& e)
-    {
+    catch (const kj::Exception& e){
         LOG_ERROR <<e.getDescription().cStr()<< LOG_ENDL;
         ret = false;
     }
+    catch (...)
+    {
+        ret = false;
+    }
     //-------end-------
     LOG_ERROR <<"client : i want getFaceList   end!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<< LOG_ENDL;
     //ret = cameraWrapper.faceCache.getFaceListPb(pBufPB, buffSize);

--
Gitblit v1.8.0