houxiao
2017-06-13 4b914a5d7e3d7971cb3e3ed49047fa331bd74da3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#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_AndroidSurfaceViewRender.h>
#include <PL_SensetimeFaceTrack.h>
#include <PL_Paint.h>
 
//#include "looper.h"
#include <android/native_window_jni.h>
#include <media/NdkMediaCodec.h>
 
#include <pthread.h>
#include <jni.h>
 
class CameraWrapper
{
public:
    PipeLine* pipeLineDecoderDetector;
    PipeLine* pipeLineAnalyzer;
    PipeLine* pipeLineRender;
 
    PL_RTSPClient_Config rtspConfig;
    PL_AndroidMediaCodecDecoder_Config amcdConfig;
    PL_AndroidSurfaceViewRender_Config asvrConfig;
    SensetimeFaceTrackConfig sftConfig;
 
    int cameraIdx;
    JavaVM* javaVM;
    JNIEnv* javaEnv;
    jclass faceCallbackClazz;
    jmethodID faceCallbackFunc;
    void* windowRender;
    void* windowDecode;
 
    pthread_t live_daemon_thid;
    bool running;
    
    bool faceCacheLocked;
    //FaceCache faceCache;
    FaceCacheForPLBG faceCache;
 
    PLPLContext plplContext;
 
    CameraWrapper() : 
        pipeLineDecoderDetector(nullptr), pipeLineAnalyzer(nullptr), pipeLineRender(nullptr), rtspConfig(), amcdConfig(), asvrConfig(), sftConfig(),
        cameraIdx(0), javaVM(nullptr), javaEnv(nullptr), faceCallbackClazz(0), faceCallbackFunc(0), windowRender(nullptr), windowDecode(nullptr),
        live_daemon_thid(0), running(false),
        faceCacheLocked(false), faceCache(),
        plplContext()
    {
    }
    
    ~CameraWrapper();
    
    bool start();
    void stop();
    bool initPl();
    
    void lockFace();
    void releaseFace();
 
private:
    static void* live_daemon_thd(void* arg);
};
 
#endif