派生自 development/c++

pansen
2019-03-07 d3b7bbe7102cd089680a828f5d8f6402c8cf6342
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
#include "RecordVideoElement.h"
#include <basic/util/app/AppPreference.hpp>
 
RecordVideoElement::RecordVideoElement(int index, std::string rtsp)
    : m_nIndex(std::to_string(index)), m_strRtsp(rtsp),
      loopRecordClient(appPref.getStringData("loopRecord.proxy"), appPref.getStringData("loopRecord.ip"),
                       appPref.getIntData("loopRecord.port"), "tcp") {
 
}
 
//#todo index int -> string
RecordVideoElement::RecordVideoElement(std::string index, std::string rtsp)
    : m_nIndex(index), m_strRtsp(rtsp),
      loopRecordClient(appPref.getStringData("loopRecord.proxy"), appPref.getStringData("loopRecord.ip"),
                       appPref.getIntData("loopRecord.port"), "tcp") {
 
}
 
RecordVideoElement::~RecordVideoElement() {
 
}
 
std::string RecordVideoElement::startRecord() {
    return callStartRecord(m_strRtsp);
}
 
std::string RecordVideoElement::callStartRecord(std::string jsonValue) {
    try {
        auto server = loopRecordClient.getServer();
        return server->addCamera(m_nIndex, jsonValue);
    }
    catch (std::exception &e) {
        ERR(e.what())
        return "";
    }
}
 
std::string RecordVideoElement::startRecord(std::string json) {
    return callStartRecord(json);
}
 
void RecordVideoElement::endRecord() {
    try {
        auto server = loopRecordClient.getServer();
        server->removeCamera(m_nIndex);
    }
    catch (std::exception &e) {
        ERR(e.what())
    }
}
 
void RecordVideoElement::feedDog() {
    try {
        auto server = loopRecordClient.getServer();
        server->feedDog(m_nIndex);
        //INFO("feedDog:" + m_nIndex);
    }
    catch (std::exception &e) {
        ERR(e.what())
    }
}