houxiao
2017-08-02 afcb649c8a2785c6095be5762c6077f9e15afd1a
VisitFace/RtspNativeCodec/app/src/main/cpp/CameraWrapper.h
@@ -1,48 +1,69 @@
#ifndef __CameraWrapper_H__
#define __CameraWrapper_H__
#define MAX_FACE 5
#define MAX_FACE_WIDTH 240
#define MAX_FACE_HEIGHT 320
#include "FaceCache.h"
#include <PipeLine.h>
#include <PL_RTSPClient.h>
#include <PL_AndroidMediaCodecDecoder.h>
#include <PL_SensetimeFaceTrack.h>
#include <PL_AndroidSurfaceViewRender.h>
#include <PL_SensetimeFaceTrackMultiTrd.h>
#include <PL_Paint.h>
#include <PL_Scale.h>
//#include "looper.h"
#include <android/native_window_jni.h>
#include <media/NdkMediaCodec.h>
#include <pthread.h>
#define MAX_FACE 5
#define MAX_FACE_WIDTH 240
#define MAX_FACE_HEIGHT 320
//#define USE_ST_SDK
#include <jni.h>
class CameraWrapper
{
public:
   PipeLine* pipeLine;
   PipeLine* pipeLineDecoderDetector;
   PipeLine* pipeLineAnalyzer;
   PipeLine* pipeLineRender;
   PL_RTSPClient_Config rtspConfig;
   PL_AndroidMediaCodecDecoder_Config amcdConfig;
   PL_AndroidSurfaceViewRender_Config asvrConfig;
   SensetimeFaceTrackConfig sftConfig;
   PL_Scale_Config plScaleCfg;
   int cameraIdx;
   jmethodID faceCallback;
   ANativeWindow* window;
   JavaVM* javaVM;
   JNIEnv* javaEnv;
   jclass faceCallbackClazz;
   jmethodID faceCallbackFunc;
   void* windowRender;
   void* windowDecode;
   pthread_t decoder_thid;
   pthread_t live_daemon_thid;
   pthread_mutex_t live_daemon_mut;
   bool running;
   volatile bool killed;
   time_t lastAliveTime;
   bool faceCacheLocked;
   FaceCache faceCache;
   //FaceCache faceCache;
   FaceCacheForPLBG faceCache;
   PLPLContext plplContext;
   std::map<int, std::wstring> faceLabels;
   std::string fontPath;
   CameraWrapper() : 
      pipeLine(nullptr), rtspConfig(), amcdConfig(), sftConfig(),
      cameraIdx(0), faceCallback(0), window(nullptr),
      live_daemon_thid(0), running(false),
      faceCacheLocked(false), faceCache()
      pipeLineDecoderDetector(nullptr), pipeLineAnalyzer(nullptr), pipeLineRender(nullptr), rtspConfig(), amcdConfig(), asvrConfig(), sftConfig(),
      cameraIdx(0), javaVM(nullptr), javaEnv(nullptr), faceCallbackClazz(0), faceCallbackFunc(0), windowRender(nullptr), windowDecode(nullptr),
      decoder_thid(0), live_daemon_thid(0), live_daemon_mut(), running(false), killed(false), lastAliveTime(0),
      faceCacheLocked(false), faceCache(),
      plplContext(), faceLabels(), fontPath()
   {
   }
   
@@ -51,12 +72,18 @@
   bool start();
   void stop();
   bool initPl();
   void lockFace();
   void releaseFace();
   void setFaceLabel(int st_track_id, const std::wstring& label);
private:
   static void* live_daemon_thd(void* arg);
   static void* decoder_thd(void *arg);
   static void* live_daemon_thd(void *arg);
   bool resetPl();
   bool initPl_DecoderPl();
};
#endif