2014-03-08 12:07:47 +01:00
|
|
|
/*
|
|
|
|
* satip.c: A plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <vdr/plugin.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "device.h"
|
|
|
|
#include "discover.h"
|
2014-12-05 22:14:40 +01:00
|
|
|
#include "log.h"
|
2014-11-11 19:23:41 +01:00
|
|
|
#include "poller.h"
|
2014-03-08 12:07:47 +01:00
|
|
|
#include "setup.h"
|
|
|
|
|
2014-04-05 23:45:52 +02:00
|
|
|
#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x072400
|
2014-05-11 16:11:28 +02:00
|
|
|
#warning "CURL version >= 7.36.0 is recommended"
|
2014-04-05 23:45:52 +02:00
|
|
|
#endif
|
|
|
|
|
2015-02-08 21:35:35 +01:00
|
|
|
#if defined(APIVERSNUM) && APIVERSNUM < 20107
|
|
|
|
#error "VDR-2.1.7 API version or greater is required!"
|
2014-03-08 12:07:47 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GITVERSION
|
|
|
|
#define GITVERSION ""
|
|
|
|
#endif
|
|
|
|
|
2015-02-08 21:35:35 +01:00
|
|
|
const char VERSION[] = "2.2.0" GITVERSION;
|
2014-03-08 12:07:47 +01:00
|
|
|
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
|
|
|
|
|
|
|
|
class cPluginSatip : public cPlugin {
|
|
|
|
private:
|
|
|
|
unsigned int deviceCountM;
|
2014-11-04 21:32:12 +01:00
|
|
|
cSatipDiscoverServers *serversM;
|
2014-11-03 22:57:08 +01:00
|
|
|
void ParseServer(const char *paramP);
|
2015-01-11 00:49:59 +01:00
|
|
|
int ParseCicams(const char *valueP, int *cicamsP);
|
2014-10-31 21:07:33 +01:00
|
|
|
int ParseSources(const char *valueP, int *sourcesP);
|
2014-03-08 12:07:47 +01:00
|
|
|
int ParseFilters(const char *valueP, int *filtersP);
|
|
|
|
public:
|
|
|
|
cPluginSatip(void);
|
|
|
|
virtual ~cPluginSatip();
|
|
|
|
virtual const char *Version(void) { return VERSION; }
|
|
|
|
virtual const char *Description(void) { return tr(DESCRIPTION); }
|
|
|
|
virtual const char *CommandLineHelp(void);
|
|
|
|
virtual bool ProcessArgs(int argc, char *argv[]);
|
|
|
|
virtual bool Initialize(void);
|
|
|
|
virtual bool Start(void);
|
|
|
|
virtual void Stop(void);
|
|
|
|
virtual void Housekeeping(void);
|
|
|
|
virtual void MainThreadHook(void);
|
|
|
|
virtual cString Active(void);
|
|
|
|
virtual time_t WakeupTime(void);
|
|
|
|
virtual const char *MainMenuEntry(void) { return NULL; }
|
|
|
|
virtual cOsdObject *MainMenuAction(void);
|
|
|
|
virtual cMenuSetupPage *SetupMenu(void);
|
|
|
|
virtual bool SetupParse(const char *Name, const char *Value);
|
|
|
|
virtual bool Service(const char *Id, void *Data = NULL);
|
|
|
|
virtual const char **SVDRPHelpPages(void);
|
|
|
|
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
|
|
|
|
};
|
|
|
|
|
|
|
|
cPluginSatip::cPluginSatip(void)
|
|
|
|
: deviceCountM(1),
|
2014-11-04 21:32:12 +01:00
|
|
|
serversM(NULL)
|
2014-03-08 12:07:47 +01:00
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Initialize any member variables here.
|
|
|
|
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
|
|
|
|
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
|
|
|
|
}
|
|
|
|
|
|
|
|
cPluginSatip::~cPluginSatip()
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Clean up after yourself!
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *cPluginSatip::CommandLineHelp(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Return a string that describes all known command line options.
|
2014-11-04 21:32:12 +01:00
|
|
|
return " -d <num>, --devices=<number> set number of devices to be created\n"
|
2015-01-05 19:09:45 +01:00
|
|
|
" -t <mode>, --trace=<mode> set the tracing mode\n"
|
2014-11-04 21:32:12 +01:00
|
|
|
" -s <ipaddr>|<model>|<desc>, --server=<ipaddr1>|<model1>|<desc1>;<ipaddr2>|<model2>|<desc2>\n"
|
2015-01-15 18:27:02 +01:00
|
|
|
" define hard-coded SAT>IP server(s)"
|
2015-01-17 16:29:21 +01:00
|
|
|
" -S, --single set the single model server mode on\n"
|
|
|
|
" -n, --noquirks disable all the server quirks\n";
|
2014-03-08 12:07:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cPluginSatip::ProcessArgs(int argc, char *argv[])
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Implement command line argument processing here if applicable.
|
|
|
|
static const struct option long_options[] = {
|
2015-01-17 16:29:21 +01:00
|
|
|
{ "devices", required_argument, NULL, 'd' },
|
|
|
|
{ "trace", required_argument, NULL, 't' },
|
|
|
|
{ "server", required_argument, NULL, 's' },
|
|
|
|
{ "single", no_argument, NULL, 'S' },
|
|
|
|
{ "noquirks", no_argument, NULL, 'n' },
|
|
|
|
{ NULL, no_argument, NULL, 0 }
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
|
2015-01-17 15:47:19 +01:00
|
|
|
cString server;
|
2014-03-08 12:07:47 +01:00
|
|
|
int c;
|
2015-01-17 16:29:21 +01:00
|
|
|
while ((c = getopt_long(argc, argv, "d:t:s:Sn", long_options, NULL)) != -1) {
|
2014-03-08 12:07:47 +01:00
|
|
|
switch (c) {
|
|
|
|
case 'd':
|
2014-12-05 23:02:51 +01:00
|
|
|
deviceCountM = strtol(optarg, NULL, 0);
|
2014-03-08 12:07:47 +01:00
|
|
|
break;
|
2014-12-21 15:11:05 +01:00
|
|
|
case 't':
|
|
|
|
SatipConfig.SetTraceMode(strtol(optarg, NULL, 0));
|
2014-12-03 18:57:23 +01:00
|
|
|
break;
|
2014-11-03 22:57:08 +01:00
|
|
|
case 's':
|
2015-01-17 15:47:19 +01:00
|
|
|
server = optarg;
|
2014-11-03 22:57:08 +01:00
|
|
|
break;
|
2015-01-15 18:27:02 +01:00
|
|
|
case 'S':
|
|
|
|
SatipConfig.SetUseSingleModelServers(true);
|
|
|
|
break;
|
2015-01-17 16:29:21 +01:00
|
|
|
case 'n':
|
|
|
|
SatipConfig.SetDisableServerQuirks(true);
|
|
|
|
break;
|
2014-03-08 12:07:47 +01:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-01-17 18:42:21 +01:00
|
|
|
// this must be done after all parameters are parsed
|
|
|
|
if (!isempty(*server))
|
|
|
|
ParseServer(*server);
|
2014-03-08 12:07:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cPluginSatip::Initialize(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Initialize any background activities the plugin shall perform.
|
|
|
|
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
|
|
|
|
error("Unable to initialize CURL");
|
2014-11-11 19:23:41 +01:00
|
|
|
cSatipPoller::GetInstance()->Initialize();
|
2014-11-16 23:23:20 +01:00
|
|
|
cSatipDiscover::GetInstance()->Initialize(serversM);
|
2014-03-08 12:07:47 +01:00
|
|
|
return cSatipDevice::Initialize(deviceCountM);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cPluginSatip::Start(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Start any background activities the plugin shall perform.
|
|
|
|
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
|
|
|
cString info = cString::sprintf("Using CURL %s", data->version);
|
|
|
|
for (int i = 0; data->protocols[i]; ++i) {
|
|
|
|
// Supported protocols: HTTP(S), RTSP, FILE
|
|
|
|
if (startswith(data->protocols[i], "rtsp"))
|
|
|
|
info = cString::sprintf("%s %s", *info, data->protocols[i]);
|
|
|
|
}
|
|
|
|
info("%s", *info);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPluginSatip::Stop(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Stop any background activities the plugin is performing.
|
|
|
|
cSatipDevice::Shutdown();
|
|
|
|
cSatipDiscover::GetInstance()->Destroy();
|
2014-11-16 23:23:20 +01:00
|
|
|
cSatipPoller::GetInstance()->Destroy();
|
2014-03-08 12:07:47 +01:00
|
|
|
curl_global_cleanup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPluginSatip::Housekeeping(void)
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Perform any cleanup or other regular tasks.
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPluginSatip::MainThreadHook(void)
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Perform actions in the context of the main program thread.
|
|
|
|
// WARNING: Use with great care - see PLUGINS.html!
|
|
|
|
}
|
|
|
|
|
|
|
|
cString cPluginSatip::Active(void)
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Return a message string if shutdown should be postponed
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t cPluginSatip::WakeupTime(void)
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Return custom wakeup time for shutdown script
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cOsdObject *cPluginSatip::MainMenuAction(void)
|
|
|
|
{
|
2014-12-14 16:45:55 +01:00
|
|
|
debug16("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Perform the action when selected from the main VDR menu.
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cMenuSetupPage *cPluginSatip::SetupMenu(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Return a setup menu in case the plugin supports one.
|
|
|
|
return new cSatipPluginSetup();
|
|
|
|
}
|
|
|
|
|
2014-11-03 22:57:08 +01:00
|
|
|
void cPluginSatip::ParseServer(const char *paramP)
|
|
|
|
{
|
2014-12-07 16:27:53 +01:00
|
|
|
debug1("%s (%s)", __PRETTY_FUNCTION__, paramP);
|
2014-11-03 22:57:08 +01:00
|
|
|
int n = 0;
|
2015-01-14 23:10:22 +01:00
|
|
|
char *s, *p = strdup(paramP);
|
2014-11-03 22:57:08 +01:00
|
|
|
char *r = strtok_r(p, ";", &s);
|
|
|
|
while (r) {
|
|
|
|
r = skipspace(r);
|
2014-12-06 16:02:45 +01:00
|
|
|
debug3("%s server[%d]=%s", __PRETTY_FUNCTION__, n, r);
|
2014-11-04 21:32:12 +01:00
|
|
|
cString serverAddr, serverModel, serverDescription;
|
|
|
|
int n2 = 0;
|
|
|
|
char *s2, *p2 = r;
|
|
|
|
char *r2 = strtok_r(p2, "|", &s2);
|
|
|
|
while (r2) {
|
2014-12-06 16:02:45 +01:00
|
|
|
debug3("%s param[%d]=%s", __PRETTY_FUNCTION__, n2, r2);
|
2014-11-04 21:32:12 +01:00
|
|
|
switch (n2++) {
|
|
|
|
case 0:
|
|
|
|
serverAddr = r2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
serverModel = r2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
serverDescription = r2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
r2 = strtok_r(NULL, "|", &s2);
|
|
|
|
}
|
|
|
|
if (*serverAddr && *serverModel && *serverDescription) {
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s ipaddr=%s model=%s desc=%s", __PRETTY_FUNCTION__, *serverAddr, *serverModel, *serverDescription);
|
2014-11-04 21:32:12 +01:00
|
|
|
if (!serversM)
|
|
|
|
serversM = new cSatipDiscoverServers();
|
2014-11-10 23:05:03 +01:00
|
|
|
serversM->Add(new cSatipDiscoverServer(*serverAddr, *serverModel, *serverDescription));
|
2014-11-04 21:32:12 +01:00
|
|
|
}
|
|
|
|
++n;
|
2014-11-03 22:57:08 +01:00
|
|
|
r = strtok_r(NULL, ";", &s);
|
|
|
|
}
|
2015-01-14 23:10:22 +01:00
|
|
|
FREE_POINTER(p);
|
2014-11-03 22:57:08 +01:00
|
|
|
}
|
|
|
|
|
2015-01-11 00:49:59 +01:00
|
|
|
int cPluginSatip::ParseCicams(const char *valueP, int *cicamsP)
|
|
|
|
{
|
|
|
|
debug1("%s (%s,)", __PRETTY_FUNCTION__, valueP);
|
|
|
|
int n = 0;
|
2015-01-14 23:10:22 +01:00
|
|
|
char *s, *p = strdup(valueP);
|
2015-01-11 00:49:59 +01:00
|
|
|
char *r = strtok_r(p, " ", &s);
|
|
|
|
while (r) {
|
|
|
|
r = skipspace(r);
|
|
|
|
debug3("%s cicams[%d]=%s", __PRETTY_FUNCTION__, n, r);
|
|
|
|
if (n < MAX_CICAM_COUNT) {
|
|
|
|
cicamsP[n++] = atoi(r);
|
|
|
|
}
|
2015-01-14 23:10:22 +01:00
|
|
|
r = strtok_r(NULL, " ", &s);
|
2015-01-11 00:49:59 +01:00
|
|
|
}
|
2015-01-14 23:10:22 +01:00
|
|
|
FREE_POINTER(p);
|
2015-01-11 00:49:59 +01:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2014-10-31 21:07:33 +01:00
|
|
|
int cPluginSatip::ParseSources(const char *valueP, int *sourcesP)
|
|
|
|
{
|
2014-12-07 16:27:53 +01:00
|
|
|
debug1("%s (%s,)", __PRETTY_FUNCTION__, valueP);
|
2014-10-31 21:07:33 +01:00
|
|
|
int n = 0;
|
2015-01-14 23:10:22 +01:00
|
|
|
char *s, *p = strdup(valueP);
|
2014-10-31 21:07:33 +01:00
|
|
|
char *r = strtok_r(p, " ", &s);
|
|
|
|
while (r) {
|
|
|
|
r = skipspace(r);
|
2014-12-06 16:02:45 +01:00
|
|
|
debug3("%s sources[%d]=%s", __PRETTY_FUNCTION__, n, r);
|
2014-10-31 21:07:33 +01:00
|
|
|
if (n < MAX_DISABLED_SOURCES_COUNT) {
|
|
|
|
sourcesP[n++] = cSource::FromString(r);
|
|
|
|
}
|
2015-01-14 23:10:22 +01:00
|
|
|
r = strtok_r(NULL, " ", &s);
|
2014-10-31 21:07:33 +01:00
|
|
|
}
|
2015-01-14 23:10:22 +01:00
|
|
|
FREE_POINTER(p);
|
2014-10-31 21:07:33 +01:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2014-03-08 12:07:47 +01:00
|
|
|
int cPluginSatip::ParseFilters(const char *valueP, int *filtersP)
|
|
|
|
{
|
2014-12-07 16:27:53 +01:00
|
|
|
debug1("%s (%s,)", __PRETTY_FUNCTION__, valueP);
|
2014-03-08 12:07:47 +01:00
|
|
|
char buffer[256];
|
|
|
|
int n = 0;
|
|
|
|
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) {
|
|
|
|
strn0cpy(buffer, valueP, sizeof(buffer));
|
|
|
|
int i = atoi(buffer);
|
2015-01-14 20:25:43 +01:00
|
|
|
debug3("%s filters[%d]=%d", __PRETTY_FUNCTION__, n, i);
|
2014-03-08 12:07:47 +01:00
|
|
|
if (i >= 0)
|
|
|
|
filtersP[n++] = i;
|
|
|
|
if ((valueP = strchr(valueP, ' ')) != NULL)
|
|
|
|
valueP++;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cPluginSatip::SetupParse(const char *nameP, const char *valueP)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
// Parse your own setup parameters and store their values.
|
2014-03-10 20:21:08 +01:00
|
|
|
if (!strcasecmp(nameP, "OperatingMode"))
|
|
|
|
SatipConfig.SetOperatingMode(atoi(valueP));
|
2015-01-05 23:58:35 +01:00
|
|
|
else if (!strcasecmp(nameP, "EnableCIExtension"))
|
|
|
|
SatipConfig.SetCIExtension(atoi(valueP));
|
2015-01-11 00:49:59 +01:00
|
|
|
else if (!strcasecmp(nameP, "CICAM")) {
|
|
|
|
int Cicams[MAX_CICAM_COUNT];
|
|
|
|
for (unsigned int i = 0; i < ELEMENTS(Cicams); ++i)
|
|
|
|
Cicams[i] = 0;
|
|
|
|
unsigned int CicamsCount = ParseCicams(valueP, Cicams);
|
|
|
|
for (unsigned int i = 0; i < CicamsCount; ++i)
|
|
|
|
SatipConfig.SetCICAM(i, Cicams[i]);
|
|
|
|
}
|
2014-03-16 18:58:09 +01:00
|
|
|
else if (!strcasecmp(nameP, "EnableEITScan"))
|
2014-03-08 12:07:47 +01:00
|
|
|
SatipConfig.SetEITScan(atoi(valueP));
|
2014-10-31 21:07:33 +01:00
|
|
|
else if (!strcasecmp(nameP, "DisabledSources")) {
|
|
|
|
int DisabledSources[MAX_DISABLED_SOURCES_COUNT];
|
2015-01-11 00:49:59 +01:00
|
|
|
for (unsigned int i = 0; i < ELEMENTS(DisabledSources); ++i)
|
2014-10-31 21:07:33 +01:00
|
|
|
DisabledSources[i] = cSource::stNone;
|
|
|
|
unsigned int DisabledSourcesCount = ParseSources(valueP, DisabledSources);
|
|
|
|
for (unsigned int i = 0; i < DisabledSourcesCount; ++i)
|
|
|
|
SatipConfig.SetDisabledSources(i, DisabledSources[i]);
|
|
|
|
}
|
2014-03-08 12:07:47 +01:00
|
|
|
else if (!strcasecmp(nameP, "DisabledFilters")) {
|
|
|
|
int DisabledFilters[SECTION_FILTER_TABLE_SIZE];
|
2015-01-11 00:49:59 +01:00
|
|
|
for (unsigned int i = 0; i < ELEMENTS(DisabledFilters); ++i)
|
2014-03-08 12:07:47 +01:00
|
|
|
DisabledFilters[i] = -1;
|
|
|
|
unsigned int DisabledFiltersCount = ParseFilters(valueP, DisabledFilters);
|
|
|
|
for (unsigned int i = 0; i < DisabledFiltersCount; ++i)
|
|
|
|
SatipConfig.SetDisabledFilters(i, DisabledFilters[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cPluginSatip::Service(const char *idP, void *dataP)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char **cPluginSatip::SVDRPHelpPages(void)
|
|
|
|
{
|
2014-12-06 16:02:45 +01:00
|
|
|
debug1("%s", __PRETTY_FUNCTION__);
|
2014-03-08 12:07:47 +01:00
|
|
|
static const char *HelpPages[] = {
|
|
|
|
"INFO [ <page> ] [ <card index> ]\n"
|
|
|
|
" Prints SAT>IP device information and statistics.\n"
|
|
|
|
" The output can be narrowed using optional \"page\""
|
|
|
|
" option: 1=general 2=pids 3=section filters.\n",
|
|
|
|
"MODE\n"
|
|
|
|
" Toggles between bit or byte information mode.\n",
|
|
|
|
"LIST\n"
|
|
|
|
" Lists active SAT>IP servers.\n",
|
2014-12-17 23:25:01 +01:00
|
|
|
"SCAN\n"
|
|
|
|
" Scans active SAT>IP servers.\n",
|
2014-11-10 22:46:45 +01:00
|
|
|
"STAT\n"
|
|
|
|
" Lists status information of SAT>IP devices.\n",
|
2014-03-08 12:07:47 +01:00
|
|
|
"CONT\n"
|
|
|
|
" Shows SAT>IP device count.\n",
|
2014-03-10 20:21:08 +01:00
|
|
|
"OPER\n"
|
|
|
|
" Toggles operating mode of SAT>IP devices.\n",
|
2014-12-21 15:11:05 +01:00
|
|
|
"TRAC [ <mode> ]\n"
|
|
|
|
" Gets and/or sets used tracing mode.\n",
|
2014-03-08 12:07:47 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
return HelpPages;
|
|
|
|
}
|
|
|
|
|
|
|
|
cString cPluginSatip::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
|
|
|
|
{
|
2014-12-07 16:27:53 +01:00
|
|
|
debug1("%s (%s, %s,)", __PRETTY_FUNCTION__, commandP, optionP);
|
2014-03-08 12:07:47 +01:00
|
|
|
if (strcasecmp(commandP, "INFO") == 0) {
|
|
|
|
int index = cDevice::ActualDevice()->CardIndex();
|
|
|
|
int page = SATIP_DEVICE_INFO_ALL;
|
|
|
|
char *opt = strdup(optionP);
|
|
|
|
char *num = skipspace(opt);
|
|
|
|
char *option = num;
|
|
|
|
while (*option && !isspace(*option))
|
|
|
|
++option;
|
|
|
|
if (*option) {
|
|
|
|
*option = 0;
|
|
|
|
option = skipspace(++option);
|
|
|
|
if (isnumber(option))
|
|
|
|
index = atoi(option);
|
|
|
|
}
|
|
|
|
if (isnumber(num)) {
|
|
|
|
page = atoi(num);
|
|
|
|
if ((page < SATIP_DEVICE_INFO_ALL) || (page > SATIP_DEVICE_INFO_FILTERS))
|
|
|
|
page = SATIP_DEVICE_INFO_ALL;
|
|
|
|
}
|
|
|
|
free(opt);
|
|
|
|
cSatipDevice *device = cSatipDevice::GetSatipDevice(index);
|
|
|
|
if (device) {
|
|
|
|
return device->GetInformation(page);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
replyCodeP = 550; // Requested action not taken
|
2014-12-07 15:19:23 +01:00
|
|
|
return cString("SATIP information not available!");
|
2014-03-08 12:07:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcasecmp(commandP, "MODE") == 0) {
|
|
|
|
unsigned int mode = !SatipConfig.GetUseBytes();
|
|
|
|
SatipConfig.SetUseBytes(mode);
|
2014-12-07 15:19:23 +01:00
|
|
|
return cString::sprintf("SATIP information mode: %s\n", mode ? "bytes" : "bits");
|
2014-03-08 12:07:47 +01:00
|
|
|
}
|
|
|
|
else if (strcasecmp(commandP, "LIST") == 0) {
|
|
|
|
cString list = cSatipDiscover::GetInstance()->GetServerList();
|
|
|
|
if (!isempty(list)) {
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
replyCodeP = 550; // Requested action not taken
|
2014-12-17 23:25:01 +01:00
|
|
|
return cString("No SATIP servers detected!");
|
2014-03-08 12:07:47 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 23:25:01 +01:00
|
|
|
else if (strcasecmp(commandP, "SCAN") == 0) {
|
|
|
|
cSatipDiscover::GetInstance()->TriggerScan();
|
|
|
|
return cString("SATIP server scan requested");
|
|
|
|
}
|
2014-11-10 22:46:45 +01:00
|
|
|
else if (strcasecmp(commandP, "STAT") == 0) {
|
|
|
|
return cSatipDevice::GetSatipStatus();
|
|
|
|
}
|
2014-03-08 12:07:47 +01:00
|
|
|
else if (strcasecmp(commandP, "CONT") == 0) {
|
2014-12-07 15:19:23 +01:00
|
|
|
return cString::sprintf("SATIP device count: %u", cSatipDevice::Count());
|
2014-03-08 12:07:47 +01:00
|
|
|
}
|
2014-03-10 20:21:08 +01:00
|
|
|
else if (strcasecmp(commandP, "OPER") == 0) {
|
|
|
|
cString mode;
|
|
|
|
SatipConfig.ToggleOperatingMode();
|
|
|
|
switch (SatipConfig.GetOperatingMode()) {
|
2014-03-13 17:23:55 +01:00
|
|
|
case cSatipConfig::eOperatingModeOff:
|
2014-03-10 20:21:08 +01:00
|
|
|
mode = "off";
|
|
|
|
break;
|
2014-03-13 17:23:55 +01:00
|
|
|
case cSatipConfig::eOperatingModeLow:
|
2014-03-10 20:21:08 +01:00
|
|
|
mode = "low";
|
|
|
|
break;
|
2014-03-13 17:23:55 +01:00
|
|
|
case cSatipConfig::eOperatingModeNormal:
|
2014-03-10 20:21:08 +01:00
|
|
|
mode = "normal";
|
|
|
|
break;
|
2014-03-13 17:23:55 +01:00
|
|
|
case cSatipConfig::eOperatingModeHigh:
|
2014-03-10 20:21:08 +01:00
|
|
|
mode = "high";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mode = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
2014-12-07 15:19:23 +01:00
|
|
|
return cString::sprintf("SATIP operating mode: %s\n", *mode);
|
2014-03-10 20:21:08 +01:00
|
|
|
}
|
2014-12-21 15:11:05 +01:00
|
|
|
else if (strcasecmp(commandP, "TRAC") == 0) {
|
2014-12-03 18:57:23 +01:00
|
|
|
if (optionP && *optionP)
|
2014-12-21 15:11:05 +01:00
|
|
|
SatipConfig.SetTraceMode(strtol(optionP, NULL, 0));
|
|
|
|
return cString::sprintf("SATIP tracing mode: 0x%04X\n", SatipConfig.GetTraceMode());
|
2014-12-03 18:57:23 +01:00
|
|
|
}
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VDRPLUGINCREATOR(cPluginSatip); // Don't touch this!
|