1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 11:37:42 +00:00

30 Commits

Author SHA1 Message Date
Rolf Ahrenberg
c07d921193 Silence "misleading-indentation" warning. 2018-03-14 23:23:27 +02:00
Rolf Ahrenberg
d333bcebb7 Remove speed limit. 2018-02-13 17:24:09 +02:00
Rolf Ahrenberg
0ce8ae7206 Avoid closing RTP/RTCP ports. 2018-02-06 22:55:52 +02:00
Rolf Ahrenberg
2c6c6ea5fd Fixed transport media change for RTCP. 2018-02-06 22:36:59 +02:00
Rolf Ahrenberg
28cc3cae63 Strip off the constructor delegation after all to broaden compiler compability. 2017-11-19 15:25:31 +02:00
Rolf Ahrenberg
0abccf2370 Merge pull request #46 from srehm/vdr-2.2.x
Configurable RTP receive buffer size
2017-11-19 14:59:50 +02:00
Stefan Rehm
f303298923 Added command line parameter to make the RTP receive bufferr size configurable. 2017-11-19 13:49:59 +01:00
Rolf Ahrenberg
f3fe1e9a13 Serialize channel switching to prevent device allocation failures. 2017-11-18 12:25:33 +02:00
Alexander Pipelka
364b4fbec7 Ignore handlers without any data. 2017-10-04 21:55:07 +03:00
Rolf Ahrenberg
b004793ef3 Cleanup section filter code. 2017-10-01 22:39:23 +03:00
Alexander Pipelka
ae403212f7 Moved send loop one level down. 2017-10-01 22:39:12 +03:00
Alexander Pipelka
09941322b1 Changed include header. 2017-10-01 22:39:03 +03:00
Alexander Pipelka
3713d1a1fa Use error() to display error messages. 2017-10-01 22:38:54 +03:00
Alexander Pipelka
2355dad37b Defined section filter send timeout. 2017-10-01 22:38:46 +03:00
Alexander Pipelka
de6c0e1f89 Minor coding-style fix. 2017-10-01 22:38:38 +03:00
Alexander Pipelka
bbd7f2da51 Removed dead sleep code (comment) in cSatipSectionFilterHandler::Action(). 2017-10-01 22:38:21 +03:00
Alexander Pipelka
e11396e84d Added transfer timeout for sectionfilter data. 2017-10-01 22:38:14 +03:00
Alexander Pipelka
dfb050c297 Fixed memory leak in cSatipSectionFilter. 2017-10-01 18:31:39 +03:00
Rolf Ahrenberg
ee88aadf60 Updated version number. 2017-08-15 09:17:11 +03:00
Sascha Kuehndel (InuSasha)
e405a31f48 fix gcc7 compiling 2017-08-15 09:11:02 +03:00
Rolf Ahrenberg
1a254029d5 Fix info messages. 2017-08-15 09:10:49 +03:00
Rolf Ahrenberg
87f9555290 Refactor the server detection script. 2017-08-15 09:10:28 +03:00
Rolf Ahrenberg
b21398938b Add a server detection script. 2017-08-15 09:10:16 +03:00
Rolf Ahrenberg
fb6282b44f Add support for interface binding via a defined source address. 2017-08-15 09:09:48 +03:00
Rolf Ahrenberg
01533ef6be Update quirks for FRITZ!WLAN Repeater DVB-C and FRITZ!Box 6490 Cable devices. 2017-08-15 09:09:16 +03:00
Tomasz Maciej Nowak
1ca7cae7e4 Add polish language 2017-08-15 09:04:52 +03:00
kavanu
974c26bdd6 added name of "KATHREIN SatIP Server" 2017-05-20 14:17:11 +03:00
Rolf Ahrenberg
ed99cfba79 Remove non-compatible RTP-over-TCP devices. 2017-02-25 14:05:32 +02:00
Frank Neumann
5b01fa34aa Update Catalan and Espanol translations. 2017-02-11 19:33:13 +02:00
Rolf Ahrenberg
0bad1c1702 Add musl-libc compatibility. 2017-01-05 17:28:28 +02:00
29 changed files with 610 additions and 151 deletions

View File

@@ -156,3 +156,12 @@ VDR Plugin 'satip' Revision History
- Added multicast and RTP-over-TCP support. - Added multicast and RTP-over-TCP support.
- Added support for activating/deactivating server on-the-fly. - Added support for activating/deactivating server on-the-fly.
- Extended command-line parameters for setting server quirks. - Extended command-line parameters for setting server quirks.
2017-08-15: Version 2.2.5
- Added Polish translation (Thanks to Tomasz Nowak).
- Updated Catalan and Spanish translations (Thanks to Gabriel Bonich).
- Added support for KATHREIN SatIP Server (Thanks to kavanu).
- Added support for FRITZ!Box 6490 Cable (Thanks to 9000h).
- Updated FRITZ!WLAN Repeater DVB-C detection for the latest firmware (Thanks to 9000h).
- Added GCC7 compatibility (Thanks to Sascha Kuehndel).

15
README
View File

@@ -52,7 +52,7 @@ separated list of "<ipaddress>|<model>|<description>" entries. The model
consists of a DVB system (DVBS2,DVBT2,DVBT,DVBC) and number of available consists of a DVB system (DVBS2,DVBT2,DVBT,DVBC) and number of available
frontends separated by a hyphen: frontends separated by a hyphen:
vdr -P 'satip -s <ipaddress>[:<port>]|<model>[:<filter>]|<description>[:<quirk>];...' vdr -P 'satip -s [<srcaddress>@]<ipaddress>[:<port>]|<model>[:<filter>]|<description>[:<quirk>];...'
vdr -P 'satip -s 192.168.0.1|DVBS2-2,DVBT2-2|OctopusNet' vdr -P 'satip -s 192.168.0.1|DVBS2-2,DVBT2-2|OctopusNet'
vdr -P 'satip -s 192.168.0.1|DVBS2-4|OctopusNet;192.168.0.2|DVBT2-4|minisatip:0x18' vdr -P 'satip -s 192.168.0.1|DVBS2-4|OctopusNet;192.168.0.2|DVBT2-4|minisatip:0x18'
vdr -P 'satip -s 192.168.0.1:554|DVBS2-2:S19.2E|OctopusNet;192.168.0.2:8554|DVBS2-4:S19.2E,S1W|minisatip' vdr -P 'satip -s 192.168.0.1:554|DVBS2-2:S19.2E|OctopusNet;192.168.0.2:8554|DVBS2-4:S19.2E,S1W|minisatip'
@@ -159,6 +159,19 @@ Notes:
from their webpage: http://www.inverto.tv/support/ from their webpage: http://www.inverto.tv/support/
An update to a newer firmware should be offered afterwards. An update to a newer firmware should be offered afterwards.
- If you are experiencing glitches in the video stream, one possible
reason can be buffer overflows in RTP receive sockets. You can verify
this by checking "receive buffer errors" counter by running "netstat -s"
command. If the counter increases every time a video glitch happens,
you should try to tweak the RTP receive buffer size with the "--rcvbuf"
(-r) plugin parameter.
A good starting point for the buffer size is to double the operating
system default value until errors disappear or the maximum value is
reached. You can check these values in Linux by checking the kernel
parameters:
$ cat /proc/sys/net/core/rmem_default
$ cat /proc/sys/net/core/rmem_max
Acknowledgements: Acknowledgements:
- Big thanks to Digital Devices GmbH for providing the Octopus Net - Big thanks to Digital Devices GmbH for providing the Octopus Net

View File

@@ -22,7 +22,8 @@ cSatipConfig::cSatipConfig(void)
transportModeM(eTransportModeUnicast), transportModeM(eTransportModeUnicast),
detachedModeM(false), detachedModeM(false),
disableServerQuirksM(false), disableServerQuirksM(false),
useSingleModelServersM(false) useSingleModelServersM(false),
rtpRcvBufSizeM(0)
{ {
for (unsigned int i = 0; i < ELEMENTS(cicamsM); ++i) for (unsigned int i = 0; i < ELEMENTS(cicamsM); ++i)
cicamsM[i] = 0; cicamsM[i] = 0;

View File

@@ -28,6 +28,7 @@ private:
int cicamsM[MAX_CICAM_COUNT]; int cicamsM[MAX_CICAM_COUNT];
int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT]; int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT];
int disabledFiltersM[SECTION_FILTER_TABLE_SIZE]; int disabledFiltersM[SECTION_FILTER_TABLE_SIZE];
size_t rtpRcvBufSizeM;
public: public:
enum eOperatingMode { enum eOperatingMode {
@@ -89,6 +90,7 @@ public:
int GetDisabledFilters(unsigned int indexP) const; int GetDisabledFilters(unsigned int indexP) const;
unsigned int GetPortRangeStart(void) const { return portRangeStartM; } unsigned int GetPortRangeStart(void) const { return portRangeStartM; }
unsigned int GetPortRangeStop(void) const { return portRangeStopM; } unsigned int GetPortRangeStop(void) const { return portRangeStopM; }
size_t GetRtpRcvBufSize(void) const { return rtpRcvBufSizeM; }
void SetOperatingMode(unsigned int operatingModeP) { operatingModeM = operatingModeP; } void SetOperatingMode(unsigned int operatingModeP) { operatingModeM = operatingModeP; }
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); } void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); }
@@ -104,6 +106,7 @@ public:
void SetDisabledFilters(unsigned int indexP, int numberP); void SetDisabledFilters(unsigned int indexP, int numberP);
void SetPortRangeStart(unsigned int rangeStartP) { portRangeStartM = rangeStartP; } void SetPortRangeStart(unsigned int rangeStartP) { portRangeStartM = rangeStartP; }
void SetPortRangeStop(unsigned int rangeStopP) { portRangeStopM = rangeStopP; } void SetPortRangeStop(unsigned int rangeStopP) { portRangeStopM = rangeStopP; }
void SetRtpRcvBufSize(size_t sizeP) { rtpRcvBufSizeM = sizeP; }
}; };
extern cSatipConfig SatipConfig; extern cSatipConfig SatipConfig;

91
detectsatip.py Executable file
View File

@@ -0,0 +1,91 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
""" Simple tool to detect SAT>IP devices as JSON.
"""
import json
import socket
import sys
import xml.etree.ElementTree as ET
import requests
SSDP_BIND = '0.0.0.0'
SSDP_ADDR = '239.255.255.250'
SSDP_PORT = 1900
SSDP_MX = 1
SSDP_ST = 'urn:ses-com:device:SatIPServer:1'
SSDP_REQUEST = 'M-SEARCH * HTTP/1.1\r\n' + \
'HOST: %s:%d\r\n' % (SSDP_ADDR, SSDP_PORT) + \
'MAN: "ssdp:discover"\r\n' + \
'MX: %d\r\n' % (SSDP_MX, ) + \
'ST: %s\r\n' % (SSDP_ST, ) + \
'\r\n'
def parse_satip_xml(data):
""" Parse SAT>IP XML data.
Args:
data (str): XML input data..
Returns:
dict: Parsed SAT>IP device name and frontend information.
"""
result = {'name': '', 'frontends': {}}
if data:
root = ET.fromstring(data)
name = root.find('.//*/{urn:schemas-upnp-org:device-1-0}friendlyName')
result['name'] = name.text
satipcap = root.find('.//*/{urn:ses-com:satip}X_SATIPCAP')
caps = {}
for system in satipcap.text.split(","):
cap = system.split("-")
if cap:
count = int(cap[1])
if cap[0] in caps:
count = count + caps[cap[0]]
caps[cap[0]] = count
result['frontends'] = caps
return result
def detect_satip_devices():
""" Detect available SAT>IP devices by sending a broadcast message.
Returns:
list: Found SAT>IP devices.
"""
urls = []
devices = []
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setblocking(0)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except BaseException:
pass
sock.settimeout(1)
sock.bind((SSDP_BIND, SSDP_PORT))
sock.sendto(SSDP_REQUEST, (SSDP_ADDR, SSDP_PORT))
try:
while 1:
data = sock.recv(1024)
if data:
for row in data.split('\r\n'):
if 'LOCATION:' in row:
url = row.replace('LOCATION:', '').strip()
if url in urls:
continue
urls.append(url)
info = requests.get(url, timeout=2)
devices.append(parse_satip_xml(info.text))
else:
break
except BaseException:
pass
sock.close()
return devices
if __name__ == '__main__':
json.dump(detect_satip_devices(), fp=sys.stdout, sort_keys=True, indent=2)

View File

@@ -15,6 +15,8 @@
static cSatipDevice * SatipDevicesS[SATIP_MAX_DEVICES] = { NULL }; static cSatipDevice * SatipDevicesS[SATIP_MAX_DEVICES] = { NULL };
cMutex cSatipDevice::mutexS = cMutex();
cSatipDevice::cSatipDevice(unsigned int indexP) cSatipDevice::cSatipDevice(unsigned int indexP)
: deviceIndexM(indexP), : deviceIndexM(indexP),
isPacketDeliveredM(false), isPacketDeliveredM(false),
@@ -22,7 +24,7 @@ cSatipDevice::cSatipDevice(unsigned int indexP)
deviceNameM(*cString::sprintf("%s %d", *DeviceType(), deviceIndexM)), deviceNameM(*cString::sprintf("%s %d", *DeviceType(), deviceIndexM)),
channelM(), channelM(),
createdM(0), createdM(0),
mutexM() tunedM()
{ {
unsigned int bufsize = (unsigned int)SATIP_BUFFER_SIZE; unsigned int bufsize = (unsigned int)SATIP_BUFFER_SIZE;
bufsize -= (bufsize % TS_SIZE); bufsize -= (bufsize % TS_SIZE);
@@ -42,6 +44,8 @@ cSatipDevice::cSatipDevice(unsigned int indexP)
cSatipDevice::~cSatipDevice() cSatipDevice::~cSatipDevice()
{ {
debug1("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM); debug1("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
// Release immediately any pending conditional wait
tunedM.Broadcast();
// Stop section handler // Stop section handler
StopSectionHandler(); StopSectionHandler();
DELETE_POINTER(pSectionFilterHandlerM); DELETE_POINTER(pSectionFilterHandlerM);
@@ -339,6 +343,7 @@ bool cSatipDevice::MaySwitchTransponder(const cChannel *channelP) const
bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
{ {
cMutexLock MutexLock(&mutexS); // Global lock to prevent any simultaneous zapping
debug9("%s (%d, %d) [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, liveViewP, deviceIndexM); debug9("%s (%d, %d) [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, liveViewP, deviceIndexM);
if (channelP) { if (channelP) {
cDvbTransponderParameters dtp(channelP->Parameters()); cDvbTransponderParameters dtp(channelP->Parameters());
@@ -356,6 +361,8 @@ bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
if (pTunerM && pTunerM->SetSource(server, channelP->Transponder(), *params, deviceIndexM)) { if (pTunerM && pTunerM->SetSource(server, channelP->Transponder(), *params, deviceIndexM)) {
channelM = *channelP; channelM = *channelP;
deviceNameM = cString::sprintf("%s %d %s", *DeviceType(), deviceIndexM, *cSatipDiscover::GetInstance()->GetServerString(server)); deviceNameM = cString::sprintf("%s %d %s", *DeviceType(), deviceIndexM, *cSatipDiscover::GetInstance()->GetServerString(server));
// Wait for actual channel tuning to prevent simultaneous frontend allocation failures
tunedM.TimedWait(mutexS, eTuningTimeoutMs);
return true; return true;
} }
} }
@@ -367,6 +374,13 @@ bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
return false; return false;
} }
void cSatipDevice::SetChannelTuned(void)
{
debug9("%s () [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
// Release immediately any pending conditional wait
tunedM.Broadcast();
}
bool cSatipDevice::SetPid(cPidHandle *handleP, int typeP, bool onP) bool cSatipDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
{ {
debug12("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM); debug12("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM);

View File

@@ -18,7 +18,7 @@
class cSatipDevice : public cDevice, public cSatipPidStatistics, public cSatipBufferStatistics, public cSatipDeviceIf { class cSatipDevice : public cDevice, public cSatipPidStatistics, public cSatipBufferStatistics, public cSatipDeviceIf {
// static ones // static ones
public: public:
static unsigned int deviceCount; static cMutex mutexS;
static bool Initialize(unsigned int DeviceCount); static bool Initialize(unsigned int DeviceCount);
static void Shutdown(void); static void Shutdown(void);
static unsigned int Count(void); static unsigned int Count(void);
@@ -28,7 +28,8 @@ public:
// private parts // private parts
private: private:
enum { enum {
eReadyTimeoutMs = 2000 // in milliseconds eReadyTimeoutMs = 2000, // in milliseconds
eTuningTimeoutMs = 1000 // in milliseconds
}; };
unsigned int deviceIndexM; unsigned int deviceIndexM;
bool isPacketDeliveredM; bool isPacketDeliveredM;
@@ -39,7 +40,7 @@ private:
cSatipTuner *pTunerM; cSatipTuner *pTunerM;
cSatipSectionFilterHandler *pSectionFilterHandlerM; cSatipSectionFilterHandler *pSectionFilterHandlerM;
cTimeMs createdM; cTimeMs createdM;
cMutex mutexM; cCondVar tunedM;
// constructor & destructor // constructor & destructor
public: public:
@@ -107,6 +108,7 @@ public:
// for internal device interface // for internal device interface
public: public:
virtual void WriteData(u_char *bufferP, int lengthP); virtual void WriteData(u_char *bufferP, int lengthP);
virtual void SetChannelTuned(void);
virtual int GetId(void); virtual int GetId(void);
virtual int GetPmtPid(void); virtual int GetPmtPid(void);
virtual int GetCISlot(void); virtual int GetCISlot(void);

View File

@@ -13,6 +13,7 @@ public:
cSatipDeviceIf() {} cSatipDeviceIf() {}
virtual ~cSatipDeviceIf() {} virtual ~cSatipDeviceIf() {}
virtual void WriteData(u_char *bufferP, int lengthP) = 0; virtual void WriteData(u_char *bufferP, int lengthP) = 0;
virtual void SetChannelTuned(void) = 0;
virtual int GetId(void) = 0; virtual int GetId(void) = 0;
virtual int GetPmtPid(void) = 0; virtual int GetPmtPid(void) = 0;
virtual int GetCISlot(void) = 0; virtual int GetCISlot(void) = 0;

View File

@@ -32,7 +32,7 @@ bool cSatipDiscover::Initialize(cSatipDiscoverServers *serversP)
if (instanceS) { if (instanceS) {
if (serversP) { if (serversP) {
for (cSatipDiscoverServer *s = serversP->First(); s; s = serversP->Next(s)) for (cSatipDiscoverServer *s = serversP->First(); s; s = serversP->Next(s))
instanceS->AddServer(s->IpAddress(), s->IpPort(), s->Model(), s->Filters(), s->Description(), s->Quirk()); instanceS->AddServer(s->SrcAddress(), s->IpAddress(), s->IpPort(), s->Model(), s->Filters(), s->Description(), s->Quirk());
} }
else else
instanceS->Activate(); instanceS->Activate();
@@ -271,12 +271,12 @@ void cSatipDiscover::ParseDeviceInfo(const char *addrP, const int portP)
model = modelNode.text().as_string("DVBS2-1"); model = modelNode.text().as_string("DVBS2-1");
} }
#endif #endif
AddServer(addrP, portP, model, NULL, desc, cSatipServer::eSatipQuirkNone); AddServer(NULL, addrP, portP, model, NULL, desc, cSatipServer::eSatipQuirkNone);
} }
void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP) void cSatipDiscover::AddServer(const char *srcAddrP, const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP)
{ {
debug1("%s (%s, %d, %s, %s, %s, %d)", __PRETTY_FUNCTION__, addrP, portP, modelP, filtersP, descP, quirkP); debug1("%s (%s, %s, %d, %s, %s, %s, %d)", __PRETTY_FUNCTION__, srcAddrP, addrP, portP, modelP, filtersP, descP, quirkP);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
if (SatipConfig.GetUseSingleModelServers() && modelP && !isempty(modelP)) { if (SatipConfig.GetUseSingleModelServers() && modelP && !isempty(modelP)) {
int n = 0; int n = 0;
@@ -285,9 +285,9 @@ void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *m
while (r) { while (r) {
r = skipspace(r); r = skipspace(r);
cString desc = cString::sprintf("%s #%d", !isempty(descP) ? descP : "MyBrokenHardware", n++); cString desc = cString::sprintf("%s #%d", !isempty(descP) ? descP : "MyBrokenHardware", n++);
cSatipServer *tmp = new cSatipServer(addrP, portP, r, filtersP, desc, quirkP); cSatipServer *tmp = new cSatipServer(srcAddrP, addrP, portP, r, filtersP, desc, quirkP);
if (!serversM.Update(tmp)) { if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s' Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none"); info("Adding server '%s|%s|%s' Bind: %s Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->SrcAddress()) ? tmp->SrcAddress() : "default", !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
serversM.Add(tmp); serversM.Add(tmp);
} }
else else
@@ -297,9 +297,9 @@ void cSatipDiscover::AddServer(const char *addrP, const int portP, const char *m
FREE_POINTER(p); FREE_POINTER(p);
} }
else { else {
cSatipServer *tmp = new cSatipServer(addrP, portP, modelP, filtersP, descP, quirkP); cSatipServer *tmp = new cSatipServer(srcAddrP, addrP, portP, modelP, filtersP, descP, quirkP);
if (!serversM.Update(tmp)) { if (!serversM.Update(tmp)) {
info("Adding server '%s|%s|%s' Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none"); info("Adding server '%s|%s|%s' Bind: %s Filters: %s CI: %s Quirks: %s", tmp->Address(), tmp->Model(), tmp->Description(), !isempty(tmp->SrcAddress()) ? tmp->SrcAddress() : "default", !isempty(tmp->Filters()) ? tmp->Filters() : "none", tmp->HasCI() ? "yes" : "no", tmp->HasQuirk() ? tmp->Quirks() : "none");
serversM.Add(tmp); serversM.Add(tmp);
} }
else else
@@ -391,6 +391,13 @@ bool cSatipDiscover::HasServerCI(cSatipServer *serverP)
return serversM.HasCI(serverP); return serversM.HasCI(serverP);
} }
cString cSatipDiscover::GetSourceAddress(cSatipServer *serverP)
{
debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM);
return serversM.GetSrcAddress(serverP);
}
cString cSatipDiscover::GetServerAddress(cSatipServer *serverP) cString cSatipDiscover::GetServerAddress(cSatipServer *serverP)
{ {
debug16("%s", __PRETTY_FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);

View File

@@ -23,17 +23,19 @@ class cSatipDiscoverServer : public cListObject {
private: private:
int ipPortM; int ipPortM;
int quirkM; int quirkM;
cString srcAddressM;
cString ipAddressM; cString ipAddressM;
cString descriptionM; cString descriptionM;
cString modelM; cString modelM;
cString filtersM; cString filtersM;
public: public:
cSatipDiscoverServer(const char *ipAddressP, const int ipPortP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP) cSatipDiscoverServer(const char *srcAddressP, const char *ipAddressP, const int ipPortP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP)
{ {
ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; filtersM = filtersP; descriptionM = descriptionP; quirkM = quirkP; srcAddressM = srcAddressP; ipAddressM = ipAddressP; ipPortM = ipPortP; modelM = modelP; filtersM = filtersP; descriptionM = descriptionP; quirkM = quirkP;
} }
int IpPort(void) { return ipPortM; } int IpPort(void) { return ipPortM; }
int Quirk(void) { return quirkM; } int Quirk(void) { return quirkM; }
const char *SrcAddress(void) { return *srcAddressM; }
const char *IpAddress(void) { return *ipAddressM; } const char *IpAddress(void) { return *ipAddressM; }
const char *Model(void) { return *modelM; } const char *Model(void) { return *modelM; }
const char *Filters(void) { return *filtersM; } const char *Filters(void) { return *filtersM; }
@@ -69,7 +71,7 @@ private:
void Deactivate(void); void Deactivate(void);
int ParseRtspPort(void); int ParseRtspPort(void);
void ParseDeviceInfo(const char *addrP, const int portP); void ParseDeviceInfo(const char *addrP, const int portP);
void AddServer(const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP); void AddServer(const char *srcAddrP, const char *addrP, const int portP, const char *modelP, const char *filtersP, const char *descP, const int quirkP);
void Fetch(const char *urlP); void Fetch(const char *urlP);
// constructor // constructor
cSatipDiscover(); cSatipDiscover();
@@ -98,6 +100,7 @@ public:
bool IsServerQuirk(cSatipServer *serverP, int quirkP); bool IsServerQuirk(cSatipServer *serverP, int quirkP);
bool HasServerCI(cSatipServer *serverP); bool HasServerCI(cSatipServer *serverP);
cString GetServerAddress(cSatipServer *serverP); cString GetServerAddress(cSatipServer *serverP);
cString GetSourceAddress(cSatipServer *serverP);
int GetServerPort(cSatipServer *serverP); int GetServerPort(cSatipServer *serverP);
cString GetServerList(void); cString GetServerList(void);
int NumProvidedSystems(void); int NumProvidedSystems(void);

View File

@@ -166,6 +166,7 @@ cString GetTransponderUrlParameters(const cChannel *channelP)
if ((channelP->Rid() % 100) > 0) if ((channelP->Rid() % 100) > 0)
q += snprintf(q, STBUFLEFT, "&fe=%d", channelP->Rid() % 100); q += snprintf(q, STBUFLEFT, "&fe=%d", channelP->Rid() % 100);
ST(" S *") q += snprintf(q, STBUFLEFT, "src=%d&", ((src > 0) && (src <= 255)) ? src : 1); ST(" S *") q += snprintf(q, STBUFLEFT, "src=%d&", ((src > 0) && (src <= 255)) ? src : 1);
if (freq >= 0L)
q += snprintf(q, STBUFLEFT, "freq=%s", *dtoa(freq, "%lg")); q += snprintf(q, STBUFLEFT, "freq=%s", *dtoa(freq, "%lg"));
ST(" S *") q += snprintf(q, STBUFLEFT, "&pol=%c", tolower(dtp.Polarization())); ST(" S *") q += snprintf(q, STBUFLEFT, "&pol=%c", tolower(dtp.Polarization()));
ST(" S *") q += PrintUrlString(q, STBUFLEFT, dtp.RollOff(), SatipRollOffValues); ST(" S *") q += PrintUrlString(q, STBUFLEFT, dtp.RollOff(), SatipRollOffValues);

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2016 Rolf Ahrenberg # Copyright (C) 2007-2017 Rolf Ahrenberg
# This file is distributed under the same license as the satip package. # This file is distributed under the same license as the satip package.
# Gabriel Bonich, 2014-2015 # Gabriel Bonich, 2014-2017
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 2.2.4\n" "Project-Id-Version: vdr-satip 2.2.5\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2016-12-18 12:18+0200\n" "POT-Creation-Date: 2017-08-15 08:15+0300\n"
"PO-Revision-Date: 2016-12-18 12:18+0200\n" "PO-Revision-Date: 2017-08-15 08:15+0300\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n" "Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Catalan <vdr@linuxtv.org>\n" "Language-Team: Catalan <vdr@linuxtv.org>\n"
"Language: ca\n" "Language: ca\n"
@@ -86,13 +86,13 @@ msgid "high"
msgstr "Alt" msgstr "Alt"
msgid "Unicast" msgid "Unicast"
msgstr "" msgstr "Unicast"
msgid "Multicast" msgid "Multicast"
msgstr "" msgstr "Multicast"
msgid "RTP-over-TCP" msgid "RTP-over-TCP"
msgstr "" msgstr "RTP-per sobre-TCP"
msgid "Button$Devices" msgid "Button$Devices"
msgstr "Dispositius" msgstr "Dispositius"
@@ -188,7 +188,7 @@ msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definir un filtre mal comportar a la llista negra." msgstr "Definir un filtre mal comportar a la llista negra."
msgid "Transport mode" msgid "Transport mode"
msgstr "" msgstr "Tipus de Transmissió"
msgid "" msgid ""
"Define which transport mode shall be used.\n" "Define which transport mode shall be used.\n"

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2016 Rolf Ahrenberg # Copyright (C) 2007-2017 Rolf Ahrenberg
# This file is distributed under the same license as the satip package. # This file is distributed under the same license as the satip package.
# Frank Neumann, 2014-2016 # Frank Neumann, 2014-2017
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 2.2.4\n" "Project-Id-Version: vdr-satip 2.2.5\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2016-12-18 12:18+0200\n" "POT-Creation-Date: 2017-08-15 08:15+0300\n"
"PO-Revision-Date: 2016-12-18 12:18+0200\n" "PO-Revision-Date: 2017-08-15 08:15+0300\n"
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n" "Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
"Language-Team: German <vdr@linuxtv.org>\n" "Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n" "Language: de\n"

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2016 Rolf Ahrenberg # Copyright (C) 2007-2017 Rolf Ahrenberg
# This file is distributed under the same license as the satip package. # This file is distributed under the same license as the satip package.
# Gabriel Bonich, 2014-2015 # Gabriel Bonich, 2014-2017
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 2.2.4\n" "Project-Id-Version: vdr-satip 2.2.5\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2016-12-18 12:18+0200\n" "POT-Creation-Date: 2017-08-15 08:15+0300\n"
"PO-Revision-Date: 2016-12-18 12:18+0200\n" "PO-Revision-Date: 2017-08-15 08:15+0300\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n" "Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Spanish <vdr@linuxtv.org>\n" "Language-Team: Spanish <vdr@linuxtv.org>\n"
"Language: es\n" "Language: es\n"
@@ -86,13 +86,13 @@ msgid "high"
msgstr "Alto" msgstr "Alto"
msgid "Unicast" msgid "Unicast"
msgstr "" msgstr "Unicast"
msgid "Multicast" msgid "Multicast"
msgstr "" msgstr "Multicast"
msgid "RTP-over-TCP" msgid "RTP-over-TCP"
msgstr "" msgstr "RTP-antes que-TCP"
msgid "Button$Devices" msgid "Button$Devices"
msgstr "Dispositivos" msgstr "Dispositivos"
@@ -188,7 +188,7 @@ msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Define un filtro para poner en la lista negra." msgstr "Define un filtro para poner en la lista negra."
msgid "Transport mode" msgid "Transport mode"
msgstr "" msgstr "Tipo de Transmisión"
msgid "" msgid ""
"Define which transport mode shall be used.\n" "Define which transport mode shall be used.\n"

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file. # VDR plugin language source file.
# Copyright (C) 2007-2016 Rolf Ahrenberg # Copyright (C) 2007-2017 Rolf Ahrenberg
# This file is distributed under the same license as the satip package. # This file is distributed under the same license as the satip package.
# Rolf Ahrenberg, 2015-2016 # Rolf Ahrenberg, 2015-2017
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-satip 2.2.4\n" "Project-Id-Version: vdr-satip 2.2.5\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2016-12-18 12:18+0200\n" "POT-Creation-Date: 2017-08-15 08:15+0300\n"
"PO-Revision-Date: 2016-12-18 12:18+0200\n" "PO-Revision-Date: 2017-08-15 08:15+0300\n"
"Last-Translator: Rolf Ahrenberg\n" "Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n" "Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n" "Language: fi\n"

206
po/pl_PL.po Normal file
View File

@@ -0,0 +1,206 @@
# VDR plugin language source file.
# Copyright (C) 2007-2017 Rolf Ahrenberg
# This file is distributed under the same license as the vdr-satip package.
# Tomasz Maciej Nowak, 2017
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-satip 2.2.5\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2017-08-15 08:15+0300\n"
"PO-Revision-Date: 2017-08-15 08:15+0300\n"
"Last-Translator: Tomasz Maciej Nowak <tomek_n@o2.pl>\n"
"Language-Team: Polish <vdr@linuxtv.org>\n"
"Language: pl_PL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
msgid "PAT (0x00)"
msgstr "PAT (0x00)"
msgid "NIT (0x40)"
msgstr "NIT (0x40)"
msgid "SDT (0x42)"
msgstr "SDT (0x42)"
msgid "EIT (0x4E/0x4F/0x5X/0x6X)"
msgstr "EIT (0x4E/0x4F/0x5X/0x6X)"
msgid "TDT (0x70)"
msgstr "TDT (0x70)"
msgid "SAT>IP information not available!"
msgstr "Informacja o SAT>IP niedostępna!"
msgid "SAT>IP Devices"
msgstr "Urządzenia SAT>IP"
msgid "SAT>IP Server"
msgstr "Serwer SAT>IP"
msgid "Address"
msgstr "Adres"
msgid "Model"
msgstr "Model"
msgid "Description"
msgstr "Opis"
msgid "CI extension"
msgstr "Rozszerzenie CI"
msgid "Creation date"
msgstr "Data produkcji"
msgid "SAT>IP Device Status"
msgstr "Status urządzenia SAT>IP"
msgid "SAT>IP Information"
msgstr "SAT>IP - informacje"
msgid "General"
msgstr "Główne"
msgid "Pids"
msgstr "Pidy"
msgid "Filters"
msgstr "Filtry"
msgid "Bits/bytes"
msgstr "Bity/bajty"
msgid "off"
msgstr "wyłączone"
msgid "low"
msgstr "niski"
msgid "normal"
msgstr "normalny"
msgid "high"
msgstr "wysoki"
msgid "Unicast"
msgstr "Unicast"
msgid "Multicast"
msgstr "Multicast"
msgid "RTP-over-TCP"
msgstr "RTP-over-TCP"
msgid "Button$Devices"
msgstr "Urządzenia"
msgid "Operating mode"
msgstr "Tryb pracy"
msgid ""
"Define the used operating mode for all SAT>IP devices:\n"
"\n"
"off - devices are disabled\n"
"low - devices are working at the lowest priority\n"
"normal - devices are working within normal parameters\n"
"high - devices are working at the highest priority"
msgstr ""
"Określa tryb pracy wszystkich urządzeń SAT>IP:\n"
"\n"
"wyłączone - urządzenia są wyłączone\n"
"niski - urządzenia pracują z najniższym priorytetem\n"
"normalny - urządzenia pracują z normalnymi parametrami\n"
"wysoki - urządzenia pracują z najwyższym priorytetem"
msgid "Enable CI extension"
msgstr "Włącz rozszerzenie CI"
msgid ""
"Define whether a CI extension shall be used.\n"
"\n"
"This setting enables integrated CI/CAM handling found in some SAT>IP hardware (e.g. Digital Devices OctopusNet)."
msgstr ""
"Określa czy korzystać z rozszerzenia CI.\n"
"\n"
"To ustawienie włącza obsługę dostępnego czytnika CI/CAM w niektórych urządzeniach SAT>IP (np. Digital Devices OctopusNet)."
msgid "CI/CAM"
msgstr "CI/CAM"
msgid ""
"Define a desired CAM type for the CI slot.\n"
"\n"
"The '---' option lets SAT>IP hardware do the auto-selection."
msgstr ""
"Określa typ modułu CAM w czytniku CI.\n"
"\n"
"Opcja '---' pozwala urządzeniu SAT>IP automatycznie wybrać typ."
msgid "Enable EPG scanning"
msgstr "Włącz skanowanie EPG"
msgid ""
"Define whether the EPG background scanning shall be used.\n"
"\n"
"This setting disables the automatic EIT scanning functionality for all SAT>IP devices."
msgstr ""
"Określa czy przeprowadzać skanowanie EPG w tle.\n"
"\n"
"To ustawienie wyłącza funkcję automatycznego skanowania EIT dla wszystkich urządzeń SAT>IP."
msgid "Disabled sources"
msgstr "Wyłączone źródła"
msgid "none"
msgstr "brak"
msgid ""
"Define number of sources to be disabled.\n"
"\n"
"SAT>IP servers might not have all satellite positions available and such sources can be blacklisted here."
msgstr ""
"Określa liczbę wyłączonych źródeł.\n"
"\n"
"Serwery SAT>IP mogą nie mieć dostępu do niektórych pozycji satelitarnych, więc tutaj można je wyłączyć."
msgid "Define a source to be blacklisted."
msgstr "Określ źródła do wyłączenia."
msgid "Disabled filters"
msgstr "Wyłączone filtry"
msgid ""
"Define number of section filters to be disabled.\n"
"\n"
"Certain section filters might cause some unwanted behaviour to VDR such as time being falsely synchronized. By blacklisting the filters here, useful section data can be left intact for VDR to process."
msgstr ""
"Określa liczbę wyłączonych filtrów sekcji.\n"
"\n"
"Niektóre filtry sekcji mogą powodować niezamierzone efekty w VDR, takie jak zły czas synchronizacji. Poprzez wyłączenie niektórych filtrów, użyteczne dane sekcji będą dostępne do przetworzenia dla VDR."
msgid "Filter"
msgstr "Filtr"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Określa filtry powodujące zakłócenia, które mają być wyłączone."
msgid "Transport mode"
msgstr "Tryb"
msgid ""
"Define which transport mode shall be used.\n"
"\n"
"Unicast, Multicast, RTP-over-TCP"
msgstr ""
"Określa tryb transmisji.\n"
"Unicast, Multicast, RTP-over-TCP."
msgid "Active SAT>IP servers:"
msgstr "Aktywne serwery SAT>IP:"
msgid "Help"
msgstr "Pomoc"

7
rtp.c
View File

@@ -14,7 +14,8 @@
#include "rtp.h" #include "rtp.h"
cSatipRtp::cSatipRtp(cSatipTunerIf &tunerP) cSatipRtp::cSatipRtp(cSatipTunerIf &tunerP)
: tunerM(tunerP), : cSatipSocket(SatipConfig.GetRtpRcvBufSize()),
tunerM(tunerP),
bufferLenM(eRtpPacketReadCount * eMaxUdpPacketSizeB), bufferLenM(eRtpPacketReadCount * eMaxUdpPacketSizeB),
bufferM(MALLOC(unsigned char, bufferLenM)), bufferM(MALLOC(unsigned char, bufferLenM)),
lastErrorReportM(0), lastErrorReportM(0),
@@ -45,7 +46,7 @@ void cSatipRtp::Close(void)
sequenceNumberM = -1; sequenceNumberM = -1;
if (packetErrorsM) { if (packetErrorsM) {
info("Detected %d RTP packet errors [device %d]", packetErrorsM, tunerM.GetId()); info("Detected %d RTP packet error%s [device %d]", packetErrorsM, packetErrorsM == 1 ? "": "s", tunerM.GetId());
packetErrorsM = 0; packetErrorsM = 0;
lastErrorReportM = time(NULL); lastErrorReportM = time(NULL);
} }
@@ -80,7 +81,7 @@ int cSatipRtp::GetHeaderLength(unsigned char *bufferP, unsigned int lengthP)
else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) { else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) {
packetErrorsM++; packetErrorsM++;
if (time(NULL) - lastErrorReportM > eReportIntervalS) { if (time(NULL) - lastErrorReportM > eReportIntervalS) {
info("Detected %d RTP packet errors [device %d]", packetErrorsM, tunerM.GetId()); info("Detected %d RTP packet error%s [device %d]", packetErrorsM, packetErrorsM == 1 ? "": "s", tunerM.GetId());
packetErrorsM = 0; packetErrorsM = 0;
lastErrorReportM = time(NULL); lastErrorReportM = time(NULL);
} }

19
rtsp.c
View File

@@ -164,9 +164,6 @@ void cSatipRtsp::Create(void)
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_TIMEOUT_MS, (long)eConnectTimeoutMs); SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_TIMEOUT_MS, (long)eConnectTimeoutMs);
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_CONNECTTIMEOUT_MS, (long)eConnectTimeoutMs); SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_CONNECTTIMEOUT_MS, (long)eConnectTimeoutMs);
// Limit download speed (bytes/s)
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_MAX_RECV_SPEED_LARGE, eMaxDownloadSpeedMBits * 131072L);
// Set user-agent // Set user-agent
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s (device %d)", PLUGIN_NAME_I18N, VERSION, tunerM.GetId())); SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s (device %d)", PLUGIN_NAME_I18N, VERSION, tunerM.GetId()));
} }
@@ -193,6 +190,22 @@ void cSatipRtsp::Reset(void)
Create(); Create();
} }
bool cSatipRtsp::SetInterface(const char *bindAddrP)
{
debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, bindAddrP, tunerM.GetId());
bool result = true;
CURLcode res = CURLE_OK;
if (handleM && !isempty(bindAddrP)) {
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_INTERFACE, *cString::sprintf("host!%s", bindAddrP));
}
else {
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_INTERFACE, NULL);
}
return result;
}
bool cSatipRtsp::Options(const char *uriP) bool cSatipRtsp::Options(const char *uriP)
{ {
debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, uriP, tunerM.GetId()); debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, uriP, tunerM.GetId());

2
rtsp.h
View File

@@ -27,7 +27,6 @@ private:
enum { enum {
eConnectTimeoutMs = 1500, // in milliseconds eConnectTimeoutMs = 1500, // in milliseconds
eMaxDownloadSpeedMBits = 20, // in megabits per second
}; };
cSatipTunerIf &tunerM; cSatipTunerIf &tunerM;
@@ -59,6 +58,7 @@ public:
cString GetActiveMode(void); cString GetActiveMode(void);
cString RtspUnescapeString(const char *strP); cString RtspUnescapeString(const char *strP);
void Reset(void); void Reset(void);
bool SetInterface(const char *bindAddrP);
bool Options(const char *uriP); bool Options(const char *uriP);
bool Setup(const char *uriP, int rtpPortP, int rtcpPortP, bool useTcpP); bool Setup(const char *uriP, int rtpPortP, int rtcpPortP, bool useTcpP);
bool SetSession(const char *sessionP); bool SetSession(const char *sessionP);

26
satip.c
View File

@@ -5,6 +5,7 @@
* *
*/ */
#include <ctype.h>
#include <getopt.h> #include <getopt.h>
#include <vdr/plugin.h> #include <vdr/plugin.h>
#include "common.h" #include "common.h"
@@ -27,7 +28,7 @@
#define GITVERSION "" #define GITVERSION ""
#endif #endif
const char VERSION[] = "2.2.4" GITVERSION; const char VERSION[] = "2.2.5" GITVERSION;
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices"); static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
class cPluginSatip : public cPlugin { class cPluginSatip : public cPlugin {
@@ -90,7 +91,8 @@ const char *cPluginSatip::CommandLineHelp(void)
" -S, --single set the single model server mode on\n" " -S, --single set the single model server mode on\n"
" -n, --noquirks disable autodetection of the server quirks\n" " -n, --noquirks disable autodetection of the server quirks\n"
" -p, --portrange=<start>-<end> set a range of ports used for the RT[C]P server\n" " -p, --portrange=<start>-<end> set a range of ports used for the RT[C]P server\n"
" a minimum of 2 ports per device is required.\n"; " a minimum of 2 ports per device is required.\n"
" -r, --rcvbuf override the size of the RTP receive buffer in bytes\n";
} }
bool cPluginSatip::ProcessArgs(int argc, char *argv[]) bool cPluginSatip::ProcessArgs(int argc, char *argv[])
@@ -102,6 +104,7 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
{ "trace", required_argument, NULL, 't' }, { "trace", required_argument, NULL, 't' },
{ "server", required_argument, NULL, 's' }, { "server", required_argument, NULL, 's' },
{ "portrange",required_argument, NULL, 'p' }, { "portrange",required_argument, NULL, 'p' },
{ "rcvbuf", required_argument, NULL, 'r' },
{ "detach", no_argument, NULL, 'D' }, { "detach", no_argument, NULL, 'D' },
{ "single", no_argument, NULL, 'S' }, { "single", no_argument, NULL, 'S' },
{ "noquirks", no_argument, NULL, 'n' }, { "noquirks", no_argument, NULL, 'n' },
@@ -111,7 +114,7 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
cString server; cString server;
cString portrange; cString portrange;
int c; int c;
while ((c = getopt_long(argc, argv, "d:t:s:p:DSn", long_options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "d:t:s:p:r:DSn", long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
deviceCountM = strtol(optarg, NULL, 0); deviceCountM = strtol(optarg, NULL, 0);
@@ -134,6 +137,9 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
case 'p': case 'p':
portrange = optarg; portrange = optarg;
break; break;
case 'r':
SatipConfig.SetRtpRcvBufSize(strtol(optarg, NULL, 0));
break;
default: default:
return false; return false;
} }
@@ -232,7 +238,7 @@ void cPluginSatip::ParseServer(const char *paramP)
while (r) { while (r) {
r = skipspace(r); r = skipspace(r);
debug3("%s server[%d]=%s", __PRETTY_FUNCTION__, n, r); debug3("%s server[%d]=%s", __PRETTY_FUNCTION__, n, r);
cString serverAddr, serverModel, serverFilters, serverDescription; cString sourceAddr, serverAddr, serverModel, serverFilters, serverDescription;
int serverQuirk = cSatipServer::eSatipQuirkNone; int serverQuirk = cSatipServer::eSatipQuirkNone;
int serverPort = SATIP_DEFAULT_RTSP_PORT; int serverPort = SATIP_DEFAULT_RTSP_PORT;
int n2 = 0; int n2 = 0;
@@ -243,8 +249,14 @@ void cPluginSatip::ParseServer(const char *paramP)
switch (n2++) { switch (n2++) {
case 0: case 0:
{ {
char *r3 = strchr(r2, '@');
if (r3) {
*r3 = 0;
sourceAddr = r2;
r2 = r3 + 1;
}
serverAddr = r2; serverAddr = r2;
char *r3 = strchr(r2, ':'); r3 = strchr(r2, ':');
if (r3) { if (r3) {
serverPort = strtol(r3 + 1, NULL, 0); serverPort = strtol(r3 + 1, NULL, 0);
serverAddr = serverAddr.Truncate(r3 - r2); serverAddr = serverAddr.Truncate(r3 - r2);
@@ -277,10 +289,10 @@ void cPluginSatip::ParseServer(const char *paramP)
r2 = strtok_r(NULL, "|", &s2); r2 = strtok_r(NULL, "|", &s2);
} }
if (*serverAddr && *serverModel && *serverDescription) { if (*serverAddr && *serverModel && *serverDescription) {
debug1("%s ipaddr=%s port=%d model=%s (%s) desc=%s (%d)", __PRETTY_FUNCTION__, *serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription, serverQuirk); debug1("%s srcaddr=%s ipaddr=%s port=%d model=%s (%s) desc=%s (%d)", __PRETTY_FUNCTION__, *sourceAddr, *serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription, serverQuirk);
if (!serversM) if (!serversM)
serversM = new cSatipDiscoverServers(); serversM = new cSatipDiscoverServers();
serversM->Add(new cSatipDiscoverServer(*serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription, serverQuirk)); serversM->Add(new cSatipDiscoverServer(*sourceAddr, *serverAddr, serverPort, *serverModel, *serverFilters, *serverDescription, serverQuirk));
} }
++n; ++n;
r = strtok_r(NULL, ";", &s); r = strtok_r(NULL, ";", &s);

View File

@@ -102,8 +102,11 @@ int cSatipSectionFilter::Filter(void)
if (doneqM && !neq) if (doneqM && !neq)
return 0; return 0;
if (ringBufferM && (secLenM > 0)) if (ringBufferM && (secLenM > 0)) {
ringBufferM->Put(new cFrame(secBufM, secLenM)); cFrame* section = new cFrame(secBufM, secLenM);
if (!ringBufferM->Put(section))
DELETE_POINTER(section);
}
} }
return 0; return 0;
} }
@@ -126,7 +129,7 @@ int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
if (tsFeedpM + lenP > eDmxMaxSectionFeedSize) if (tsFeedpM + lenP > eDmxMaxSectionFeedSize)
lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM); lenP = (uint8_t)(eDmxMaxSectionFeedSize - tsFeedpM);
if (lenP <= 0) if (lenP == 0)
return 0; return 0;
memcpy(secBufBaseM + tsFeedpM, bufP, lenP); memcpy(secBufBaseM + tsFeedpM, bufP, lenP);
@@ -141,7 +144,7 @@ int cSatipSectionFilter::CopyDump(const uint8_t *bufP, uint8_t lenP)
for (n = 0; secBufpM + 2 < limit; ++n) { for (n = 0; secBufpM + 2 < limit; ++n) {
uint16_t seclen = GetLength(secBufM); uint16_t seclen = GetLength(secBufM);
if ((seclen <= 0) || (seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit)) if ((seclen > eDmxMaxSectionSize) || ((seclen + secBufpM) > limit))
return 0; return 0;
secLenM = seclen; secLenM = seclen;
if (pusiSeenM) if (pusiSeenM)
@@ -209,27 +212,28 @@ void cSatipSectionFilter::Process(const uint8_t* dataP)
} }
} }
bool cSatipSectionFilter::Send(void) void cSatipSectionFilter::Send(void)
{ {
bool result = false;
cFrame *section = ringBufferM->Get(); cFrame *section = ringBufferM->Get();
if (section) { if (section) {
uchar *data = section->Data(); uchar *data = section->Data();
int count = section->Count(); int count = section->Count();
if (data && (count > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) { if (data && (count > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) {
ssize_t len = send(socketM[1], data, count, MSG_EOR); if (send(socketM[1], data, count, MSG_EOR) > 0) {
ERROR_IF(len < 0 && errno != EAGAIN, "send()");
if (len > 0) {
ringBufferM->Drop(section);
result = !!ringBufferM->Available();
// Update statistics // Update statistics
AddSectionStatistic(len, 1); AddSectionStatistic(count, 1);
} }
else if (errno != EAGAIN)
error("failed to send section data (%i bytes) [device=%d]", count, deviceIndexM);
} }
ringBufferM->Drop(section);
} }
return result;
} }
int cSatipSectionFilter::Available(void) const
{
return ringBufferM->Available();
}
cSatipSectionFilterHandler::cSatipSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP) cSatipSectionFilterHandler::cSatipSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP)
: cThread(cString::sprintf("SATIP#%d section handler", deviceIndexP)), : cThread(cString::sprintf("SATIP#%d section handler", deviceIndexP)),
@@ -267,30 +271,48 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
Delete(i); Delete(i);
} }
void cSatipSectionFilterHandler::SendAll(void)
{
cMutexLock MutexLock(&mutexM);
bool pendingData;
do {
pendingData = false;
// zero polling structures
memset(pollFdsM, 0, sizeof(pollFdsM));
// assemble all handlers to poll (use -1 to ignore handlers)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && filtersM[i]->Available() != 0) {
pollFdsM[i].fd = filtersM[i]->GetFd();
pollFdsM[i].events = POLLOUT;
pendingData = true;
}
else
pollFdsM[i].fd = -1;
}
// exit if there isn't any pending data or we time out
if (!pendingData || poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0)
return;
// send data (if available)
for (unsigned int i = 0; i < eMaxSecFilterCount && pendingData; ++i) {
if (pollFdsM[i].revents & POLLOUT)
filtersM[i]->Send();
}
} while (pendingData);
}
void cSatipSectionFilterHandler::Action(void) void cSatipSectionFilterHandler::Action(void)
{ {
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
bool processed = false;
// Do the thread loop // Do the thread loop
while (Running()) { while (Running()) {
// Send demuxed section packets through all filters uchar *p = NULL;
bool retry = false;
mutexM.Lock();
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && filtersM[i]->Send())
retry = true;
}
mutexM.Unlock();
if (retry)
continue;
// Read one TS packet
if (ringBufferM) {
int len = 0; int len = 0;
if (processed) { // Process all pending TS packets
ringBufferM->Del(TS_SIZE); while ((p = ringBufferM->Get(len)) != NULL) {
processed = false;
}
uchar *p = ringBufferM->Get(len);
if (p && (len >= TS_SIZE)) { if (p && (len >= TS_SIZE)) {
if (*p != TS_SYNC_BYTE) { if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < len; ++i) { for (int i = 1; i < len; ++i) {
@@ -310,11 +332,12 @@ void cSatipSectionFilterHandler::Action(void)
filtersM[i]->Process(p); filtersM[i]->Process(p);
} }
mutexM.Unlock(); mutexM.Unlock();
processed = true; ringBufferM->Del(TS_SIZE);
continue;
} }
} }
cCondWait::SleepMs(10); // to avoid busy loop and reduce cpu load
// Send demuxed section packets through all filters
SendAll();
} }
debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM); debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
} }

View File

@@ -8,6 +8,7 @@
#ifndef __SATIP_SECTIONFILTER_H #ifndef __SATIP_SECTIONFILTER_H
#define __SATIP_SECTIONFILTER_H #define __SATIP_SECTIONFILTER_H
#include <poll.h>
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
@@ -55,23 +56,27 @@ public:
cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP); cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
virtual ~cSatipSectionFilter(); virtual ~cSatipSectionFilter();
void Process(const uint8_t* dataP); void Process(const uint8_t* dataP);
bool Send(void); void Send(void);
int GetFd(void) { return socketM[0]; } int GetFd(void) { return socketM[0]; }
uint16_t GetPid(void) const { return pidM; } uint16_t GetPid(void) const { return pidM; }
int Available(void) const;
}; };
class cSatipSectionFilterHandler : public cThread { class cSatipSectionFilterHandler : public cThread {
private: private:
enum { enum {
eMaxSecFilterCount = 32 eMaxSecFilterCount = 32,
eSecFilterSendTimeoutMs = 10
}; };
cRingBufferLinear *ringBufferM; cRingBufferLinear *ringBufferM;
cMutex mutexM; cMutex mutexM;
int deviceIndexM; int deviceIndexM;
cSatipSectionFilter *filtersM[eMaxSecFilterCount]; cSatipSectionFilter *filtersM[eMaxSecFilterCount];
struct pollfd pollFdsM[eMaxSecFilterCount];
bool Delete(unsigned int indexP); bool Delete(unsigned int indexP);
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const; bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
void SendAll(void);
protected: protected:
virtual void Action(void); virtual void Action(void);

View File

@@ -80,8 +80,9 @@ bool cSatipFrontends::Detach(int deviceIdP, int transponderP)
// --- cSatipServer ----------------------------------------------------------- // --- cSatipServer -----------------------------------------------------------
cSatipServer::cSatipServer(const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP) cSatipServer::cSatipServer(const char *srcAddressP, const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP)
: addressM((addressP && *addressP) ? addressP : "0.0.0.0"), : srcAddressM((srcAddressP && *srcAddressP) ? srcAddressP : ""),
addressM((addressP && *addressP) ? addressP : "0.0.0.0"),
modelM((modelP && *modelP) ? modelP : "DVBS-1"), modelM((modelP && *modelP) ? modelP : "DVBS-1"),
filtersM((filtersP && *filtersP) ? filtersP : ""), filtersM((filtersP && *filtersP) ? filtersP : ""),
descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"), descriptionM(!isempty(descriptionP) ? descriptionP : "MyBrokenHardware"),
@@ -123,18 +124,19 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo
quirkM |= eSatipQuirkSessionId; quirkM |= eSatipQuirkSessionId;
// These devices contain support for RTP over TCP: // These devices contain support for RTP over TCP:
if (strstr(*descriptionM, "minisatip") || // minisatip server if (strstr(*descriptionM, "minisatip") || // minisatip server
strstr(*descriptionM, "DVBViewer") || // DVBViewer Media Server strstr(*descriptionM, "DVBViewer") // DVBViewer Media Server
strstr(*descriptionM, "GSSBOX") || // Grundig Sat Systems GSS.box DSI 400
strstr(*descriptionM, "DIGIBIT") || // Telestar Digibit R1
strstr(*descriptionM, "Triax SatIP Converter") // Triax TSS 400
) )
quirkM |= eSatipQuirkRtpOverTcp; quirkM |= eSatipQuirkRtpOverTcp;
// These devices contain a play (add/delpids) parameter bug: // These devices contain a play (add/delpids) parameter bug:
if (strstr(*descriptionM, "fritzdvbc") // Fritz!WLAN Repeater DVB-C if (strstr(*descriptionM, "FRITZ!Box 6490 Cable") || // FRITZ!Box 6490 Cable
strstr(*descriptionM, "FRITZ!WLAN Repeater DVB-C") || // FRITZ!WLAN Repeater DVB-C
strstr(*descriptionM, "fritzdvbc") // FRITZ!WLAN Repeater DVB-C (old firmware)
) )
quirkM |= eSatipQuirkPlayPids; quirkM |= eSatipQuirkPlayPids;
// These devices contain a frontend locking bug: // These devices contain a frontend locking bug:
if (strstr(*descriptionM, "fritzdvbc") || // Fritz!WLAN Repeater DVB-C if (strstr(*descriptionM, "FRITZ!Box 6490 Cable") || // FRITZ!Box 6490 Cable
strstr(*descriptionM, "FRITZ!WLAN Repeater DVB-C") || // FRITZ!WLAN Repeater DVB-C
strstr(*descriptionM, "fritzdvbc") || // FRITZ!WLAN Repeater DVB-C (old firmware)
strstr(*descriptionM, "Schwaiger Sat>IP Server") // Schwaiger MS41IP strstr(*descriptionM, "Schwaiger Sat>IP Server") // Schwaiger MS41IP
) )
quirkM |= eSatipQuirkForceLock; quirkM |= eSatipQuirkForceLock;
@@ -150,8 +152,8 @@ cSatipServer::cSatipServer(const char *addressP, const int portP, const char *mo
// These devices don't support auto-detection of pilot tones // These devices don't support auto-detection of pilot tones
if (strstr(*descriptionM, "GSSBOX") || // Grundig Sat Systems GSS.box DSI 400 if (strstr(*descriptionM, "GSSBOX") || // Grundig Sat Systems GSS.box DSI 400
strstr(*descriptionM, "DIGIBIT") || // Telestar Digibit R1 strstr(*descriptionM, "DIGIBIT") || // Telestar Digibit R1
strstr(*descriptionM, "Triax SatIP Converter") // Triax TSS 400 strstr(*descriptionM, "Triax SatIP Converter") || // Triax TSS 400
// Kathrein ExIP 414/E strstr(*descriptionM, "KATHREIN SatIP Server") // Kathrein ExIP 414/E
) )
quirkM |= eSatipQuirkForcePilot; quirkM |= eSatipQuirkForcePilot;
} }
@@ -446,6 +448,18 @@ void cSatipServers::Cleanup(uint64_t intervalMsP)
} }
} }
cString cSatipServers::GetSrcAddress(cSatipServer *serverP)
{
cString address = "";
for (cSatipServer *s = First(); s; s = Next(s)) {
if (s == serverP) {
address = s->SrcAddress();
break;
}
}
return address;
}
cString cSatipServers::GetAddress(cSatipServer *serverP) cString cSatipServers::GetAddress(cSatipServer *serverP)
{ {
cString address = ""; cString address = "";
@@ -486,7 +500,10 @@ cString cSatipServers::List(void)
{ {
cString list = ""; cString list = "";
for (cSatipServer *s = First(); s; s = Next(s)) for (cSatipServer *s = First(); s; s = Next(s))
if (isempty(s->SrcAddress()))
list = cString::sprintf("%s%c %s|%s|%s\n", *list, s->IsActive() ? '+' : '-', s->Address(), s->Model(), s->Description()); list = cString::sprintf("%s%c %s|%s|%s\n", *list, s->IsActive() ? '+' : '-', s->Address(), s->Model(), s->Description());
else
list = cString::sprintf("%s%c %s@%s|%s|%s\n", *list, s->IsActive() ? '+' : '-', s->SrcAddress(), s->Address(), s->Model(), s->Description());
return list; return list;
} }

View File

@@ -57,6 +57,7 @@ private:
enum { enum {
eSatipMaxSourceFilters = 16 eSatipMaxSourceFilters = 16
}; };
cString srcAddressM;
cString addressM; cString addressM;
cString modelM; cString modelM;
cString filtersM; cString filtersM;
@@ -84,7 +85,7 @@ public:
eSatipQuirkForcePilot = 0x40, eSatipQuirkForcePilot = 0x40,
eSatipQuirkMask = 0xFF eSatipQuirkMask = 0xFF
}; };
cSatipServer(const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP); cSatipServer(const char *srcAddressP, const char *addressP, const int portP, const char *modelP, const char *filtersP, const char *descriptionP, const int quirkP);
virtual ~cSatipServer(); virtual ~cSatipServer();
virtual int Compare(const cListObject &listObjectP) const; virtual int Compare(const cListObject &listObjectP) const;
bool Assign(int deviceIdP, int sourceP, int systemP, int transponderP); bool Assign(int deviceIdP, int sourceP, int systemP, int transponderP);
@@ -98,6 +99,7 @@ public:
int GetModulesDVBC(void); int GetModulesDVBC(void);
int GetModulesDVBC2(void); int GetModulesDVBC2(void);
void Activate(bool onOffP) { activeM = onOffP; } void Activate(bool onOffP) { activeM = onOffP; }
const char *SrcAddress(void) { return *srcAddressM; }
const char *Address(void) { return *addressM; } const char *Address(void) { return *addressM; }
const char *Model(void) { return *modelM; } const char *Model(void) { return *modelM; }
const char *Filters(void) { return *filtersM; } const char *Filters(void) { return *filtersM; }
@@ -128,6 +130,7 @@ public:
bool HasCI(cSatipServer *serverP); bool HasCI(cSatipServer *serverP);
void Cleanup(uint64_t intervalMsP = 0); void Cleanup(uint64_t intervalMsP = 0);
cString GetAddress(cSatipServer *serverP); cString GetAddress(cSatipServer *serverP);
cString GetSrcAddress(cSatipServer *serverP);
cString GetString(cSatipServer *serverP); cString GetString(cSatipServer *serverP);
int GetPort(cSatipServer *serverP); int GetPort(cSatipServer *serverP);
cString List(void); cString List(void);

View File

@@ -105,7 +105,7 @@ cSatipServerInfo::cSatipServerInfo(cSatipServer *serverP)
: cOsdMenu(tr("SAT>IP Server"), 20), : cOsdMenu(tr("SAT>IP Server"), 20),
serverM(serverP), serverM(serverP),
activeM(serverP && serverP->IsActive()), activeM(serverP && serverP->IsActive()),
addressM(serverP ? serverP->Address() : "---"), addressM(serverP ? (isempty(serverP->SrcAddress()) ? serverP->Address() : *cString::sprintf("%s@%s", serverP->SrcAddress(), serverP->Address())) : "---"),
modelM(serverP ? serverP->Model() : "---"), modelM(serverP ? serverP->Model() : "---"),
descriptionM(serverP ? serverP->Description() : "---"), descriptionM(serverP ? serverP->Description() : "---"),
ciExtensionM(serverP && serverP->HasCI() ? trVDR("yes") : trVDR("no")), ciExtensionM(serverP && serverP->HasCI() ? trVDR("yes") : trVDR("no")),
@@ -167,7 +167,7 @@ cSatipServerItem::cSatipServerItem(cSatipServer *serverP)
{ {
SetSelectable(true); SetSelectable(true);
// Must begin with a '#' character! // Must begin with a '#' character!
SetText(*cString::sprintf("%s %s (%s)\t%s", serverM->IsActive() ? "+" : "-", serverM->Address(), serverM->Model(), serverM->Description())); SetText(*cString::sprintf("%s %s (%s)\t%s", serverM->IsActive() ? "+" : "-", isempty(serverM->SrcAddress()) ? serverM->Address() : *cString::sprintf("%s@%s", serverM->SrcAddress(), serverM->Address()), serverM->Model(), serverM->Description()));
} }
void cSatipServerItem::SetMenuItem(cSkinDisplayMenu *displayMenuP, int indexP, bool currentP, bool selectableP) void cSatipServerItem::SetMenuItem(cSkinDisplayMenu *displayMenuP, int indexP, bool currentP, bool selectableP)

View File

@@ -19,13 +19,35 @@
#include "log.h" #include "log.h"
#include "socket.h" #include "socket.h"
#if defined(__GLIBC__)
#if defined(__GLIBC_PREREQ)
#if !__GLIBC_PREREQ(2,12)
#define __SATIP_DISABLE_RECVMMSG__
#endif
#endif
#endif
cSatipSocket::cSatipSocket() cSatipSocket::cSatipSocket()
: socketPortM(0), : socketPortM(0),
socketDescM(-1), socketDescM(-1),
isMulticastM(false), isMulticastM(false),
useSsmM(false), useSsmM(false),
streamAddrM(htonl(INADDR_ANY)), streamAddrM(htonl(INADDR_ANY)),
sourceAddrM(htonl(INADDR_ANY)) sourceAddrM(htonl(INADDR_ANY)),
rcvBufSizeM(0)
{
debug1("%s", __PRETTY_FUNCTION__);
memset(&sockAddrM, 0, sizeof(sockAddrM));
}
cSatipSocket::cSatipSocket(size_t rcvBufSizeP)
: socketPortM(0),
socketDescM(-1),
isMulticastM(false),
useSsmM(false),
streamAddrM(htonl(INADDR_ANY)),
sourceAddrM(htonl(INADDR_ANY)),
rcvBufSizeM(rcvBufSizeP)
{ {
debug1("%s", __PRETTY_FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddrM, 0, sizeof(sockAddrM));
@@ -70,6 +92,11 @@ bool cSatipSocket::Open(const int portP, const bool reuseP)
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0,
"setsockopt(IP_PKTINFO)", Close(), return false); "setsockopt(IP_PKTINFO)", Close(), return false);
#endif // __FreeBSD__ #endif // __FreeBSD__
// Tweak receive buffer size if requested
if (rcvBufSizeM > 0) {
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_RCVBUF, &rcvBufSizeM, sizeof(rcvBufSizeM)) < 0,
"setsockopt(SO_RCVBUF)", Close(), return false);
}
// Bind socket // Bind socket
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddrM, 0, sizeof(sockAddrM));
sockAddrM.sin_family = AF_INET; sockAddrM.sin_family = AF_INET;
@@ -101,7 +128,7 @@ bool cSatipSocket::OpenMulticast(const int portP, const char *streamAddrP, const
void cSatipSocket::Close(void) void cSatipSocket::Close(void)
{ {
debug1("%s sockerPort=%d", __PRETTY_FUNCTION__, socketPortM); debug1("%s socketPort=%d", __PRETTY_FUNCTION__, socketPortM);
// Check if socket exists // Check if socket exists
if (socketDescM >= 0) { if (socketDescM >= 0) {
Leave(); Leave();
@@ -289,7 +316,7 @@ int cSatipSocket::ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRec
error("%s Invalid parameter(s)", __PRETTY_FUNCTION__); error("%s Invalid parameter(s)", __PRETTY_FUNCTION__);
return -1; return -1;
} }
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,12) #ifndef __SATIP_DISABLE_RECVMMSG__
// Initialize iov and msgh structures // Initialize iov and msgh structures
struct mmsghdr mmsgh[elementCountP]; struct mmsghdr mmsgh[elementCountP];
struct iovec iov[elementCountP]; struct iovec iov[elementCountP];

View File

@@ -19,12 +19,15 @@ private:
bool useSsmM; bool useSsmM;
in_addr_t streamAddrM; in_addr_t streamAddrM;
in_addr_t sourceAddrM; in_addr_t sourceAddrM;
size_t rcvBufSizeM;
bool CheckAddress(const char *addrP, in_addr_t *inAddrP); bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
bool Join(void); bool Join(void);
bool Leave(void); bool Leave(void);
public: public:
cSatipSocket(); cSatipSocket();
explicit cSatipSocket(size_t rcvBufSizeP);
virtual ~cSatipSocket(); virtual ~cSatipSocket();
bool Open(const int portP = 0, const bool reuseP = false); bool Open(const int portP = 0, const bool reuseP = false);
bool OpenMulticast(const int portP, const char *streamAddrP, const char *sourceAddrP); bool OpenMulticast(const int portP, const char *streamAddrP, const char *sourceAddrP);

13
tuner.c
View File

@@ -126,6 +126,7 @@ void cSatipTuner::Action(void)
break; break;
case tsTuned: case tsTuned:
debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM); debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM);
deviceM->SetChannelTuned();
reConnectM.Set(eConnectTimeoutMs); reConnectM.Set(eConnectTimeoutMs);
idleCheck.Set(eIdleCheckTimeoutMs); idleCheck.Set(eIdleCheckTimeoutMs);
lastIdleStatus = false; lastIdleStatus = false;
@@ -222,12 +223,14 @@ bool cSatipTuner::Connect(void)
return true; return true;
} }
} }
else if (rtspM.Options(*connectionUri)) { else if (rtspM.SetInterface(nextServerM.IsValid() ? *nextServerM.GetSrcAddress() : NULL) && rtspM.Options(*connectionUri)) {
cString uri = cString::sprintf("%s?%s", *connectionUri, *streamParamM); cString uri = cString::sprintf("%s?%s", *connectionUri, *streamParamM);
bool useTcp = SatipConfig.IsTransportModeRtpOverTcp() && nextServerM.IsValid() && nextServerM.IsQuirk(cSatipServer::eSatipQuirkRtpOverTcp); bool useTcp = SatipConfig.IsTransportModeRtpOverTcp() && nextServerM.IsValid() && nextServerM.IsQuirk(cSatipServer::eSatipQuirkRtpOverTcp);
// Flush any old content // Flush any old content
//rtpM.Flush(); //rtpM.Flush();
//rtcpM.Flush(); //rtcpM.Flush();
if (useTcp)
debug1("%s Requesting TCP [device %d]", __PRETTY_FUNCTION__, deviceIdM);
if (rtspM.Setup(*uri, rtpM.Port(), rtcpM.Port(), useTcp)) { if (rtspM.Setup(*uri, rtpM.Port(), rtcpM.Port(), useTcp)) {
keepAliveM.Set(timeoutM); keepAliveM.Set(timeoutM);
if (nextServerM.IsValid()) { if (nextServerM.IsValid()) {
@@ -385,8 +388,8 @@ void cSatipTuner::SetupTransport(int rtpPortP, int rtcpPortP, const char *stream
// Adapt RTP to any transport media change // Adapt RTP to any transport media change
if (multicast != rtpM.IsMulticast() || rtpPortP != rtpM.Port()) { if (multicast != rtpM.IsMulticast() || rtpPortP != rtpM.Port()) {
cSatipPoller::GetInstance()->Unregister(rtpM); cSatipPoller::GetInstance()->Unregister(rtpM);
rtpM.Close();
if (rtpPortP >= 0) { if (rtpPortP >= 0) {
rtpM.Close();
if (multicast) if (multicast)
rtpM.OpenMulticast(rtpPortP, streamAddrP, sourceAddrP); rtpM.OpenMulticast(rtpPortP, streamAddrP, sourceAddrP);
else else
@@ -397,12 +400,12 @@ void cSatipTuner::SetupTransport(int rtpPortP, int rtcpPortP, const char *stream
// Adapt RTCP to any transport media change // Adapt RTCP to any transport media change
if (multicast != rtcpM.IsMulticast() || rtcpPortP != rtcpM.Port()) { if (multicast != rtcpM.IsMulticast() || rtcpPortP != rtcpM.Port()) {
cSatipPoller::GetInstance()->Unregister(rtcpM); cSatipPoller::GetInstance()->Unregister(rtcpM);
rtcpM.Close();
if (rtcpPortP >= 0) { if (rtcpPortP >= 0) {
rtcpM.Close();
if (multicast) if (multicast)
rtcpM.OpenMulticast(rtpPortP, streamAddrP, sourceAddrP); rtcpM.OpenMulticast(rtcpPortP, streamAddrP, sourceAddrP);
else else
rtcpM.Open(rtpPortP); rtcpM.Open(rtcpPortP);
cSatipPoller::GetInstance()->Register(rtcpM); cSatipPoller::GetInstance()->Register(rtcpM);
} }
} }

View File

@@ -69,6 +69,7 @@ public:
void Set(cSatipServer *serverP, const int transponderP) { serverM = serverP; transponderM = transponderP; } void Set(cSatipServer *serverP, const int transponderP) { serverM = serverP; transponderM = transponderP; }
void Reset(void) { serverM = NULL; transponderM = 0; } void Reset(void) { serverM = NULL; transponderM = 0; }
cString GetAddress(void) { return serverM ? cSatipDiscover::GetInstance()->GetServerAddress(serverM) : ""; } cString GetAddress(void) { return serverM ? cSatipDiscover::GetInstance()->GetServerAddress(serverM) : ""; }
cString GetSrcAddress(void) { return serverM ? cSatipDiscover::GetInstance()->GetSourceAddress(serverM) : ""; }
int GetPort(void) { return serverM ? cSatipDiscover::GetInstance()->GetServerPort(serverM) : SATIP_DEFAULT_RTSP_PORT; } int GetPort(void) { return serverM ? cSatipDiscover::GetInstance()->GetServerPort(serverM) : SATIP_DEFAULT_RTSP_PORT; }
cString GetInfo(void) { return cString::sprintf("server=%s deviceid=%d transponder=%d", serverM ? "assigned" : "null", deviceIdM, transponderM); } cString GetInfo(void) { return cString::sprintf("server=%s deviceid=%d transponder=%d", serverM ? "assigned" : "null", deviceIdM, transponderM); }
}; };