-
Notifications
You must be signed in to change notification settings - Fork 25
/
DVBAPI.cpp
194 lines (172 loc) · 4.84 KB
/
DVBAPI.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* vdr-plugin-dvbapi - softcam dvbapi plugin for VDR
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <getopt.h>
#include <vdr/plugin.h>
#include "DVBAPI.h"
#include "DVBAPISetup.h"
#include "Log.h"
#ifndef LIBDVBCSA
static const char *DECSALIB = "FFdecsa";
#else
static const char *DECSALIB = "libdvbcsa";
#endif
bool CheckExpiredCW = true;
unsigned int AdapterIndexOffset = 0;
int ENABLEFASTECM=1;
DVBAPI::DVBAPI(void)
{
sCCIAdapter = NULL;
}
DVBAPI::~DVBAPI()
{
}
const char *DVBAPI::CommandLineHelp(void)
{
return " -o N, --offset=N add constant value to all adapter indexes when\n"
" communicating with OSCam (default: 0)\n"
" -d, --disable-exp disable CW expiration check\n";
}
bool DVBAPI::ProcessArgs(int argc, char *argv[])
{
static struct option long_options[] = {
{ "offset", required_argument, NULL, 'o' },
{ "disable-exp", no_argument, NULL, 'd' },
{ NULL }
};
int c, option_index = 0;
while ((c = getopt_long(argc, argv, "o:d", long_options, &option_index)) != -1)
{
switch (c)
{
case 'o':
AdapterIndexOffset = atoi(optarg);
break;
case 'd':
CheckExpiredCW = false;
break;
default:
return false;
}
}
return true;
}
bool DVBAPI::Initialize(void)
{
// Initialize any background activities the plugin shall perform.
return true;
}
bool DVBAPI::Start(void)
{
INFOLOG("plugin version %s initializing (VDR %s)", VERSION, VDRVERSION);
INFOLOG("decryption library: %s", DECSALIB);
if (AdapterIndexOffset)
INFOLOG("Using value %d as the adapter index offset", AdapterIndexOffset);
if (!CheckExpiredCW)
INFOLOG("CW expiration check is disabled");
capmt = new CAPMT;
decsa = new DeCSA;
filter = new cDvbapiFilter;
SockHandler = new SocketHandler;
INFOLOG("Creating sCCIAdapter");
sCCIAdapter = new SCCIAdapter;
INFOLOG("plugin started");
return true;
}
void DVBAPI::Stop(void)
{
delete sCCIAdapter;
sCCIAdapter = NULL;
delete SockHandler;
SockHandler = NULL;
delete filter;
filter = NULL;
delete decsa;
decsa = NULL;
delete capmt;
capmt = NULL;
INFOLOG("plugin stopped");
}
void DVBAPI::Housekeeping(void)
{
// Perform any cleanup or other regular tasks.
}
void DVBAPI::MainThreadHook(void)
{
// Perform actions in the context of the main program thread.
// WARNING: Use with great care - see PLUGINS.html!
}
cString DVBAPI::Active(void)
{
// Return a message string if shutdown should be postponed
return NULL;
}
time_t DVBAPI::WakeupTime(void)
{
// Return custom wakeup time for shutdown script
return 0;
}
cMenuSetupPage *DVBAPI::SetupMenu(void)
{
// Return a setup menu in case the plugin supports one.
return new cMenuSetupDVBAPI;
}
bool DVBAPI::SetupParse(const char *Name, const char *Value)
{
// Parse your own setup parameters and store their values.
if (!strcasecmp(Name, CONFNAME_LOGLEVEL))
LogLevel = atoi(Value);
else if (!strcasecmp(Name, CONFNAME_OSCAMHOST))
strn0cpy(OSCamHost, Value, sizeof(OSCamHost));
else if (!strcasecmp(Name, CONFNAME_OSCAMPORT))
OSCamPort = atoi(Value);
else if (!strcasecmp(Name, CONFNAME_OSCAMFASTECM))
ENABLEFASTECM = atoi(Value);
else if (!strcasecmp(Name, CONFNAME_ADAPTERINDEXOFFSET))
{
if (AdapterIndexOffset)
INFOLOG("ignoring config parameter: dvbapi.%s (offset is forced in plugin command line)", CONFNAME_ADAPTERINDEXOFFSET);
else
AdapterIndexOffset = atoi(Value);
}
else
return false;
return true;
}
bool DVBAPI::Service(const char *Id, void *Data)
{
// Handle custom service requests from other plugins
if (Data == NULL)
return false;
if (strcmp(Id, "GetEcmInfo") == 0)
{
sDVBAPIEcmInfo *ecminfo = static_cast<sDVBAPIEcmInfo *>(Data);
return capmt->FillEcmInfo(ecminfo);
}
return false;
}
const char **DVBAPI::SVDRPHelpPages(void)
{
// Return help text for SVDRP commands this plugin implements
return NULL;
}
cString DVBAPI::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{
// Process SVDRP commands this plugin implements
return NULL;
}
VDRPLUGINCREATOR(DVBAPI); // Don't touch this!