2014-03-10 20:21:08 +01:00
|
|
|
/*
|
|
|
|
* param.c: SAT>IP plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <vdr/dvbdevice.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "param.h"
|
|
|
|
|
|
|
|
// --- cSatipParameterMaps ----------------------------------------------------
|
|
|
|
|
|
|
|
struct tSatipParameterMap {
|
|
|
|
int driverValue;
|
|
|
|
const char *satipString;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipBandwidthValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ 5000000, "&bw=5" },
|
|
|
|
{ 6000000, "&bw=6" },
|
|
|
|
{ 7000000, "&bw=7" },
|
|
|
|
{ 8000000, "&bw=8" },
|
|
|
|
{ 10000000, "&bw=10" },
|
|
|
|
{ 1712000, "&bw=1.712" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipPilotValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ PILOT_OFF, "&plts=off" },
|
|
|
|
{ PILOT_ON, "&plts=on" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ PILOT_AUTO, "" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipSisoMisoValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ 0, "&sm=0" },
|
|
|
|
{ 1, "&sm=1" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipCodeRateValues[] = {
|
|
|
|
{ FEC_NONE, "" },
|
2014-03-13 17:23:55 +01:00
|
|
|
{ FEC_1_2, "&fec=12" },
|
|
|
|
{ FEC_2_3, "&fec=23" },
|
|
|
|
{ FEC_3_4, "&fec=34" },
|
|
|
|
{ FEC_3_5, "&fec=35" },
|
|
|
|
{ FEC_4_5, "&fec=45" },
|
|
|
|
{ FEC_5_6, "&fec=56" },
|
|
|
|
{ FEC_6_7, "&fec=67" },
|
|
|
|
{ FEC_7_8, "&fec=78" },
|
|
|
|
{ FEC_8_9, "&fec=89" },
|
|
|
|
{ FEC_9_10, "&fec=910" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ FEC_AUTO, "" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipModulationValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ QPSK, "&mtype=qpsk" },
|
|
|
|
{ PSK_8, "&mtype=8psk" },
|
|
|
|
{ QAM_16, "&mtype=16qam" },
|
|
|
|
{ QAM_64, "&mtype=64qam" },
|
|
|
|
{ QAM_128, "&mtype=128qam" },
|
|
|
|
{ QAM_256, "&mtype=256qam" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ QAM_AUTO, "" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipSystemValuesSat[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ 0, "&msys=dvbs" },
|
|
|
|
{ 1, "&msys=dvbs2" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
2014-03-13 17:23:55 +01:00
|
|
|
static const tSatipParameterMap SatipSystemValuesTerrestrial[] = {
|
|
|
|
{ 0, "&msys=dvbt" },
|
|
|
|
{ 1, "&msys=dvbt2" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipSystemValuesCable[] = {
|
|
|
|
{ 0, "&msys=dvbc" },
|
|
|
|
{ 1, "&msys=dvbc2" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipTransmissionValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ TRANSMISSION_MODE_1K, "&tmode=1k" },
|
|
|
|
{ TRANSMISSION_MODE_2K, "&tmode=2k" },
|
|
|
|
{ TRANSMISSION_MODE_4K, "&tmode=4k" },
|
|
|
|
{ TRANSMISSION_MODE_8K, "&tmode=8k" },
|
|
|
|
{ TRANSMISSION_MODE_16K, "&tmode=16k" },
|
|
|
|
{ TRANSMISSION_MODE_32K, "&tmode=32k" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ TRANSMISSION_MODE_AUTO, "" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipGuardValues[] = {
|
2014-03-13 17:23:55 +01:00
|
|
|
{ GUARD_INTERVAL_1_4, "&gi=14" },
|
|
|
|
{ GUARD_INTERVAL_1_8, "&gi=18" },
|
|
|
|
{ GUARD_INTERVAL_1_16, "&gi=116" },
|
|
|
|
{ GUARD_INTERVAL_1_32, "&gi=132" },
|
|
|
|
{ GUARD_INTERVAL_1_128, "&gi=1128" },
|
|
|
|
{ GUARD_INTERVAL_19_128, "&gi=19128" },
|
|
|
|
{ GUARD_INTERVAL_19_256, "&gi=19256" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ GUARD_INTERVAL_AUTO, "" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const tSatipParameterMap SatipRollOffValues[] = {
|
|
|
|
{ ROLLOFF_AUTO, "" },
|
2014-03-13 17:23:55 +01:00
|
|
|
{ ROLLOFF_20, "&ro=0.20" },
|
|
|
|
{ ROLLOFF_25, "&ro=0.25" },
|
|
|
|
{ ROLLOFF_35, "&ro=0.35" },
|
2014-03-10 20:21:08 +01:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int SatipUserIndex(int valueP, const tSatipParameterMap *mapP)
|
|
|
|
{
|
|
|
|
const tSatipParameterMap *map = mapP;
|
|
|
|
while (map && map->driverValue != -1) {
|
|
|
|
if (map->driverValue == valueP)
|
|
|
|
return map - mapP;
|
|
|
|
map++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-13 17:23:55 +01:00
|
|
|
static int PrintUrlString(char *bufP, int lenP, int valueP, const tSatipParameterMap *mapP)
|
2014-03-10 20:21:08 +01:00
|
|
|
{
|
|
|
|
int n = SatipUserIndex(valueP, mapP);
|
2014-03-13 17:23:55 +01:00
|
|
|
return ((n >= 0) && (lenP > 0)) ? snprintf(bufP, lenP, "%s", mapP[n].satipString) : 0;
|
2014-03-10 20:21:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cString GetTransponderUrlParameters(const cChannel *channelP)
|
|
|
|
{
|
|
|
|
if (channelP) {
|
2014-03-13 17:23:55 +01:00
|
|
|
char buffer[255];
|
2014-03-10 20:21:08 +01:00
|
|
|
cDvbTransponderParameters dtp(channelP->Parameters());
|
2014-03-16 18:58:09 +01:00
|
|
|
#if defined(APIVERSNUM) && APIVERSNUM < 20106
|
|
|
|
int Pilot = PILOT_AUTO;
|
|
|
|
int T2SystemId = 0;
|
|
|
|
int SisoMiso = 0;
|
|
|
|
#else
|
|
|
|
int Pilot = dtp.Pilot();
|
|
|
|
int T2SystemId = dtp.T2SystemId();
|
|
|
|
int SisoMiso = dtp.SisoMiso();
|
|
|
|
#endif
|
2014-03-10 20:21:08 +01:00
|
|
|
float freq = channelP->Frequency();
|
|
|
|
char type = cSource::ToChar(channelP->Source());
|
|
|
|
cSource *source = Sources.Get(channelP->Source());
|
|
|
|
int src = (strchr("S", type) && source) ? atoi(source->Description()) : 1;
|
|
|
|
char *q = buffer;
|
|
|
|
*q = 0;
|
|
|
|
// Scale down frequencies to MHz
|
|
|
|
while (freq > 20000L)
|
|
|
|
freq /= 1000L;
|
|
|
|
#define ST(s) if (strchr(s, type) && (strchr(s, '0' + dtp.System() + 1) || strchr(s, '*')))
|
2014-03-13 17:23:55 +01:00
|
|
|
#define STBUFLEFT (sizeof(buffer) - (q - buffer))
|
|
|
|
q += snprintf(q, STBUFLEFT, "freq=%s", *dtoa(freq, "%.3f"));
|
|
|
|
ST(" S *") q += snprintf(q, STBUFLEFT, "&src=%d", ((src > 0) && (src <= 255)) ? src : 1);
|
|
|
|
ST("CS *") q += snprintf(q, STBUFLEFT, "&sr=%d", channelP->Srate());
|
|
|
|
ST(" S *") q += snprintf(q, STBUFLEFT, "&pol=%c", tolower(dtp.Polarization()));
|
|
|
|
ST("C T2") q += snprintf(q, STBUFLEFT, "&plp=%d", dtp.StreamId());
|
|
|
|
ST(" T2") q += snprintf(q, STBUFLEFT, "&t2id=%d", T2SystemId);
|
|
|
|
ST(" T2") q += PrintUrlString(q, STBUFLEFT, SisoMiso, SatipSisoMisoValues);
|
|
|
|
ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.Bandwidth(), SatipBandwidthValues);
|
|
|
|
ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.Guard(), SatipGuardValues);
|
|
|
|
ST("CST*") q += PrintUrlString(q, STBUFLEFT, dtp.CoderateH(), SatipCodeRateValues);
|
|
|
|
ST(" S 2") q += PrintUrlString(q, STBUFLEFT, Pilot, SatipPilotValues);
|
|
|
|
ST(" S 2") q += PrintUrlString(q, STBUFLEFT, dtp.Modulation(), SatipModulationValues);
|
|
|
|
ST("C T*") q += PrintUrlString(q, STBUFLEFT, dtp.Modulation(), SatipModulationValues);
|
|
|
|
ST(" S 2") q += PrintUrlString(q, STBUFLEFT, dtp.RollOff(), SatipRollOffValues);
|
|
|
|
ST(" S *") q += PrintUrlString(q, STBUFLEFT, dtp.System(), SatipSystemValuesSat);
|
|
|
|
ST("C *") q += PrintUrlString(q, STBUFLEFT, dtp.System(), SatipSystemValuesCable);
|
|
|
|
ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.System(), SatipSystemValuesTerrestrial);
|
|
|
|
ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.Transmission(), SatipTransmissionValues);
|
2014-03-10 20:21:08 +01:00
|
|
|
#undef ST
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|