forked from rofafor/vdr-plugin-iptv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotocoltcp.cpp
76 lines (55 loc) · 1.79 KB
/
protocoltcp.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
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
/*
* protocoludp.c: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#include <vdr/device.h>
#include "config.h"
#include "log.h"
#include "socket.h"
#include "protocoltcp.h"
cIptvProtocolTcp::cIptvProtocolTcp()
: streamAddrM(strdup("")),
streamPortM(0) {
debug1("%s", __PRETTY_FUNCTION__);
}
cIptvProtocolTcp::~cIptvProtocolTcp() {
debug1("%s", __PRETTY_FUNCTION__);
// Drop the multicast group and close the socket
cIptvProtocolTcp::Close();
// Free allocated memory
free(streamAddrM);
}
bool cIptvProtocolTcp::Open() {
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
OpenSocket(streamPortM, streamAddrM);
return true;
}
bool cIptvProtocolTcp::Close() {
debug1("%s streamAddr='%s'", __PRETTY_FUNCTION__, streamAddrM);
// Close the socket
CloseSocket();
return true;
}
int cIptvProtocolTcp::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) {
return cIptvTcpServerSocket::Read(bufferAddrP, bufferLenP);
}
bool cIptvProtocolTcp::SetSource(SourceParameter parameter) {
debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, parameter.locationP, parameter.parameterP, parameter.indexP);
if (!isempty(parameter.locationP)) {
// Update stream address and port
streamAddrM = strcpyrealloc(streamAddrM, parameter.locationP);
streamPortM = parameter.parameterP;
}
OpenSocket(streamPortM);
return true;
}
bool cIptvProtocolTcp::SetPid(int pidP, int typeP, bool onP) {
debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true;
}
cString cIptvProtocolTcp::GetInformation() {
debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("tcp://%s:%d", streamAddrM, streamPortM);
}