派生自 development/c++

pansen
2019-03-07 979bc003bce710bf300bc2bd87a8278585678763
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
#include <iostream>
#include <QtCore/QDebug>
#include <Ice/Ice.h>
#include <IceUtil/IceUtil.h>
#include "RecordVideoI.h"
#include "ImageGrabberI.h"
#include "LoopRecordVideoI.h"
#include <basic/util/app/AppPreference.hpp>
#include <basic/rpc/IceRpc.hpp>
#include <basic/util/app/AppConfig.h>
#include <basic/debug/Debug.h>
 
 
using namespace std;
 
int main2(int argc, char **argv) {
    SAVE_APP_ARGS;
    ENABLEGLOG("~/work/log/");
    auto ich = Ice::initialize(argc, argv);
 
    std::string identity = ich->getProperties()->getProperty("user.record.video.identity");
    std::string identityCapture = ich->getProperties()->getProperty("user.capture.image.identity");
    std::string identityLoop = ich->getProperties()->getProperty("user.loop.record.video.identity");
    std::string adapterName = ich->getProperties()->getProperty("user.adapter.name");
    std::string absolutePath = ich->getProperties()->getProperty("user.absolute.path");
    std::string loopAbsolutePath = ich->getProperties()->getProperty("user.loop.absolute.path");
    std::string intervalDuration = ich->getProperties()->getProperty("user.interval.duration");
    std::string ipPort = ich->getProperties()->getProperty("user.ip.port");
    std::string timeOut = ich->getProperties()->getProperty("user.timeout");
 
    appPref.setStringData("user.absolute.path", absolutePath);
    appPref.setStringData("user.loop.absolute.path", loopAbsolutePath);
    appPref.setLongData("user.interval.duration", atol(intervalDuration.c_str()));
    appPref.setStringData("user.ip.port", ipPort);
    appPref.setLongData("user.timeout", atol(timeOut.c_str()));
 
    auto adapter = ich->createObjectAdapter(adapterName);
    adapter->add(new RecordVideoI(), Ice::stringToIdentity(identity));
    adapter->add(new ImageGrabberI(), Ice::stringToIdentity(identityCapture));
    adapter->add(new LoopRecordVideoI(), Ice::stringToIdentity(identityLoop));
    adapter->activate();
    ich->waitForShutdown();
 
    return 0;
}
 
#include "jsoncpp/json/json.h"
 
int main(int argc, char **argv) {
    std::cout<<__DATE__<<" "<<__TIME__<<std::endl;
    SAVE_APP_ARGS;
    ENABLEGLOG(GET_STR_CONFIG("logPath").c_str());
    auto ich = Ice::initialize(argc, argv);
 
    std::string identity = "RecordVideoServer";
    std::string identityCapture = "CaptureVideoImgServer";
    std::string identityLoop = "LoopRecordVideoServer";
    std::string adapterName = "RecordVideoServerAdapter";
    std::string absolutePath = "build";
    // std::string loopAbsolutePath = "/home/bsk/test/";
    std::string loopAbsolutePath = appConfig.getStringProperty("cutPath");
    std::string intervalDuration = "600000";
    std::string ipPort = "192.168.1.65:8888";
    std::string timeOut = "6000000";
 
    appPref.setStringData("user.absolute.path", absolutePath);
    appPref.setStringData("user.loop.absolute.path", loopAbsolutePath);
    appPref.setLongData("user.interval.duration", atol(intervalDuration.c_str()));
    appPref.setStringData("user.ip.port", ipPort);
    appPref.setLongData("user.timeout", atol(timeOut.c_str()));
 
//    auto adapter = ich->createObjectAdapter(adapterName);
//    adapter->add(new RecordVideoI(), Ice::stringToIdentity(identity));
//    adapter->add(new ImageGrabberI(), Ice::stringToIdentity(identityCapture));
//    adapter->add(new LoopRecordVideoI(), Ice::stringToIdentity(identityLoop));
//    adapter->activate();
//    ich->waitForShutdown();
 
//    Ice::ObjectAdapterPtr adapter = ich->createObjectAdapterWithEndpoints(identityLoop + "Adapter",
//                                                                          " tcp -p " + std::to_string(10010));
//
//    adapter->add(new LoopRecordVideoI, Ice::stringToIdentity(identityLoop));
//    adapter->activate();
//    ich->waitForShutdown();
 
    IceRpcServer<LoopRecordVideoI> server("LoopRecordVideoServer", 10010, "tcp");
    server.setMessageSizeMax(1024 * 1024 * 50);
    server.setPoolInitSize(5);
    server.setPoolMaxSize(32);
    server.runWaitShutDown();
 
    return 0;
}