houxiao
2017-08-16 a188ad2e23ef190c8a044b17bc467fa3e2ae0ca5
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//
// Created by pansen on 2017/8/4.
//
 
#include "RemoteFuncClient.h"
#include "RemoteFunc.h"
#include "RtspNativeCodecJNIClient.h"
 
#include <string>
#include <iostream>
using namespace std;
 
//#todo 修改服务线程构造参数传入方式
RemoteServer<RtspFaceDetectImpl> remoteServer("192.168.1.97", 8111);
static RtspFaceViewClient* rtspFaceViewClient = nullptr;
 
void startRemoteServer()
{
    LOG_ERROR << "pansen : this is clinet" << std::endl;
    remoteServer.start();
 
    //#todo 调用位置移动
//    try
//    {
//        RtspFaceViewClient rtspFaceViewClient = RtspFaceViewClient();
//        RtspFaceView::Client& rClient = rtspFaceViewClient.getClient();
//
//        auto& waitScope = rtspFaceViewClient.getWaitScope();
//        //auto  request = rClient.abcdef();
//       // auto sendAct = request.send();
//       // sendAct.wait(waitScope);
//    }
//    catch (const kj::Exception& e)
//    {
//        cout << e.getDescription().cStr() << endl;
//        return;
//    }
    //#end
}
 
RtspFaceViewClient * getRtspFaceViewClient()
{
    if(rtspFaceViewClient == nullptr)
        rtspFaceViewClient = new RtspFaceViewClient;
    return rtspFaceViewClient;
}
 
RtspFaceViewClient::RtspFaceViewClient() :
        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 getEzRpcClient()->getWaitScope();
}
 
capnp::EzRpcClient * RtspFaceViewClient::getEzRpcClient()
{
    if (rpcClient == nullptr) {
        try
        {
            //#todo ip modify
            rpcClient = new capnp::EzRpcClient("192.168.1.94", 8112);
            //rpcClient = new capnp::EzRpcClient("192.168.1.71", 8112);
        }
        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;
}