-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvdrclient.cpp
44 lines (38 loc) · 1.21 KB
/
vdrclient.cpp
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
#include "vdrclient.h"
#include "logger.h"
VdrClient::VdrClient(std::string vdrIp, int vdrPort) {
client = new httplib::Client(vdrIp, vdrPort);
client->set_read_timeout(15, 0);
client->set_keep_alive(true);
}
VdrClient::~VdrClient() {
client->stop();
delete client;
}
bool VdrClient::ProcessTSPacket(std::string packet) {
if (auto res = client->Post("/ProcessTSPacket", packet, "text/plain")) {
if (res->status != 200) {
INFO("[remotetranscoder] Http result(ProcessTSPacket): {}", res->status);
return false;
}
} else {
// this can be reached by intention. If e.g. VDR stops the video player
auto err = res.error();
DEBUG("[remotetranscoder] Http error(ProcessTSPacket): {}", httplib::to_string(err));
return false;
}
return true;
}
bool VdrClient::Seeked() {
if (auto res = client->Get("/Seeked")) {
if (res->status != 200) {
INFO("[remotetranscoder] Http result(Seeked): {}", res->status);
return false;
}
} else {
auto err = res.error();
ERROR("[remotetranscoder] Http error(Seeked): {}", httplib::to_string(err));
return false;
}
return true;
}