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

4 Commits

Author SHA1 Message Date
Rolf Ahrenberg
f46d07a95f Added Catalan translation (Thanks to Gabriel Bonich). 2014-04-05 13:50:55 +03:00
Rolf Ahrenberg
43cc15357e Optimized re-sending. 2014-04-05 13:46:07 +03:00
Rolf Ahrenberg
5b1af5ba29 Refactored the section filtering. 2014-04-04 00:56:00 +03:00
Rolf Ahrenberg
80fc28d8cf Fixed eMinKeepAliveIntervalMs typo. 2014-04-02 21:06:37 +03:00
11 changed files with 205 additions and 106 deletions

View File

@@ -33,3 +33,10 @@ VDR Plugin 'satip' Revision History
- Added a check to write new sections only if there
is no data in the read socket.
- Fixed keepalive heartbeat again.
2014-04-05: Version 0.2.2
- Fixed the default keepalive interval.
- Refactored the section filtering.
- Added Catalan translation (Thanks to Gabriel Bonich).

View File

@@ -57,30 +57,6 @@ char *StripTags(char *strP)
return NULL;
}
int select_single_desc(int descriptorP, const int msP, const bool selectWriteP)
{
// Wait for data
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = msP * 1000L;
// Use select
fd_set infd;
fd_set outfd;
fd_set errfd;
FD_ZERO(&infd);
FD_ZERO(&outfd);
FD_ZERO(&errfd);
FD_SET(descriptorP, &errfd);
if (selectWriteP)
FD_SET(descriptorP, &outfd);
else
FD_SET(descriptorP, &infd);
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
// Check if error
ERROR_IF_RET(retval < 0, "select()", return retval);
return retval;
}
cString ChangeCase(const cString &strP, bool upperP)
{
cString res(strP);

View File

@@ -93,7 +93,6 @@ uint16_t ts_pid(const uint8_t *bufP);
uint8_t payload(const uint8_t *bufP);
const char *id_pid(const u_short pidP);
char *StripTags(char *strP);
int select_single_desc(int descriptorP, const int msP, const bool selectWriteP);
cString ChangeCase(const cString &strP, bool upperP);
struct section_filter_table_type {

137
po/ca_ES.po Normal file
View File

@@ -0,0 +1,137 @@
# VDR plugin language source file.
# Copyright (C) 2007-2014 Rolf Ahrenberg
# This file is distributed under the same license as the satip package.
# Gabriel Bonich, 2014
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-satip 0.2.2\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-04-05 04:05+0200\n"
"PO-Revision-Date: 2014-04-05 04:05+0200\n"
"Last-Translator: Gabriel Bonich <gbonich@gmail.com>\n"
"Language-Team: Catalan <vdr@linuxtv.org>\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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 Devices"
msgstr "SAT>IP Dispositius"
msgid "SAT>IP Device"
msgstr "SAT>IP Dispositiu"
msgid "Address"
msgstr "Adressa"
msgid "Model"
msgstr "Model"
msgid "Description"
msgstr "Descripció"
msgid "Creation date"
msgstr "Creació de data"
msgid "SAT>IP Information"
msgstr "SAT>IP Informació"
msgid "General"
msgstr "General"
msgid "Pids"
msgstr "Pids"
msgid "Filters"
msgstr "Filtres"
msgid "Bits/bytes"
msgstr "Bits/Bytes"
msgid "SAT>IP information not available!"
msgstr "SAT>IP Informació no disponible!"
msgid "off"
msgstr "Apagat"
msgid "low"
msgstr "Baix"
msgid "normal"
msgstr "Normal"
msgid "high"
msgstr "Alt"
msgid "Operating mode"
msgstr "Mode de operació"
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 ""
"Defineig la manera de operar de tots els SAT>IP Tuners:\n"
"\n"
"Apagat - Dispositius desactivats\n"
"Baix - Dispositius treballan a baixa prioritat\n"
"Normal - Dispositius treballan en parametres normals\n"
"Alta - Dispositius treballan a prioritat Alta"
msgid "Enable EPG scanning"
msgstr "Activa Escaneig 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 ""
"Definir si s'utilitzarà l'anàlisi en segon pla del EPG.\n"
"\n"
"Aquesta configuració desactiva la funcionalitat d'escaneig EIT automàtica per a tots els dispositius SAT>IP."
msgid "Disabled filters"
msgstr "Desactiva filtres"
msgid "none"
msgstr "no"
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 black-listing the filters here useful section data can be left intact for VDR to process."
msgstr ""
"Definir el nombre de seccions filtres per deshabilitat.\n"
"\n"
"Certs filtres de secció podrien causar un comportament no desitjat a VDR, com sincronitzar malament el temps. Per la llista negre els filtres aquí dades de la secció útil es pot deixar intacte per VDR per processar."
msgid "Filter"
msgstr "Filtra"
msgid "Define an ill-behaving filter to be blacklisted."
msgstr "Definir un filtre mal comportar a la llista negra."
msgid "Active SAT>IP devices:"
msgstr "Dispositius SAT>IP actius:"
msgid "Help"
msgstr "Ajuda"

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007-2014 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Copyright (C) 2007-2014 Rolf Ahrenberg
# This file is distributed under the same license as the satip package.
# Frank Neumann, 2014
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-satip 0.2.1\n"
"Project-Id-Version: vdr-satip 0.2.2\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-04-01 04:01+0200\n"
"PO-Revision-Date: 2014-04-01 04:01+0200\n"
"POT-Creation-Date: 2014-04-05 04:05+0200\n"
"PO-Revision-Date: 2014-04-05 04:05+0200\n"
"Last-Translator: Frank Neumann <fnu@yavdr.org>\n"
"Language-Team: German <vdr@linuxtv.org>\n"
"Language: de\n"

View File

@@ -1,14 +1,14 @@
# VDR plugin language source file.
# Copyright (C) 2007-2014 Rolf Ahrenberg & Antti Seppala
# This file is distributed under the same license as the iptv package.
# Copyright (C) 2007-2014 Rolf Ahrenberg
# This file is distributed under the same license as the satip package.
# Rolf Ahrenberg, 2014
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-satip 0.2.1\n"
"Project-Id-Version: vdr-satip 0.2.2\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2014-04-01 04:01+0200\n"
"PO-Revision-Date: 2014-04-01 04:01+0200\n"
"POT-Creation-Date: 2014-04-05 04:05+0200\n"
"PO-Revision-Date: 2014-04-05 04:05+0200\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish <vdr@linuxtv.org>\n"
"Language: fi\n"

View File

@@ -21,7 +21,7 @@
#define GITVERSION ""
#endif
const char VERSION[] = "0.2.1" GITVERSION;
const char VERSION[] = "0.2.2" GITVERSION;
static const char DESCRIPTION[] = trNOOP("SAT>IP Devices");
class cPluginSatip : public cPlugin {

View File

@@ -17,6 +17,7 @@ cSatipSectionFilter::cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_
secLenM(0),
tsFeedpM(0),
pidM(pidP),
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)),
deviceIndexM(deviceIndexP)
{
//debug("cSatipSectionFilter::%s(%d, %d)", __FUNCTION__, deviceIndexM, pidM);
@@ -48,7 +49,7 @@ cSatipSectionFilter::cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_
// Create sockets
socketM[0] = socketM[1] = -1;
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, socketM) != 0) {
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketM) != 0) {
char tmp[64];
error("Opening section filter sockets failed (device=%d pid=%d): %s", deviceIndexM, pidM, strerror_r(errno, tmp, sizeof(tmp)));
}
@@ -70,6 +71,7 @@ cSatipSectionFilter::~cSatipSectionFilter()
if (tmp >= 0)
close(tmp);
secBufM = NULL;
DELETENULL(ringBufferM);
}
inline uint16_t cSatipSectionFilter::GetLength(const uint8_t *dataP)
@@ -99,21 +101,8 @@ int cSatipSectionFilter::Filter(void)
if (doneqM && !neq)
return 0;
// There is no data in the read socket, more can be written
if ((secLenM > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) {
for (i = 0; i < eWriteMaxRetries; ++i) {
if (select_single_desc(socketM[0], 10, false))
continue;
ssize_t len = write(socketM[1], secBufM, secLenM);
ERROR_IF(len < 0, "write()");
// Update statistics
if (len >= 0)
AddSectionStatistic(len, 1);
break;
}
if (i >= eWriteMaxRetries)
debug("Skipped section write (%d bytes)", secLenM);
}
if (ringBufferM && (secLenM > 0))
ringBufferM->Put(new cFrame(secBufM, secLenM));
}
return 0;
}
@@ -219,13 +208,31 @@ void cSatipSectionFilter::Process(const uint8_t* dataP)
}
}
bool cSatipSectionFilter::Send(void)
{
bool result = false;
cFrame *section = ringBufferM->Get();
if (section) {
uchar *data = section->Data();
int count = section->Count();
if (data && (count > 0) && (socketM[1] >= 0) && (socketM[0] >= 0)) {
ssize_t len = send(socketM[1], data, count, MSG_EOR);
ERROR_IF(len < 0 && errno != EAGAIN, "send()");
if (len > 0) {
ringBufferM->Drop(section);
result = !!ringBufferM->Available();
// Update statistics
AddSectionStatistic(len, 1);
}
}
}
return result;
}
cSatipSectionFilterHandler::cSatipSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP)
:
#ifdef USE_THREADED_SECTIONFILTER
cThread("SAT>IP section handler", true),
: cThread("SAT>IP section handler"),
ringBufferM(new cRingBufferLinear(bufferLenP, TS_SIZE, false, *cString::sprintf("SAT>IP SECTION HANDLER %d", deviceIndexP))),
#endif
mutexM(),
deviceIndexM(deviceIndexP)
{
@@ -234,7 +241,6 @@ cSatipSectionFilterHandler::cSatipSectionFilterHandler(int deviceIndexP, unsigne
// Initialize filter pointers
memset(filtersM, 0, sizeof(filtersM));
#ifdef USE_THREADED_SECTIONFILTER
// Create input buffer
if (ringBufferM) {
ringBufferM->SetTimeouts(100, 100);
@@ -242,19 +248,17 @@ cSatipSectionFilterHandler::cSatipSectionFilterHandler(int deviceIndexP, unsigne
}
else
error("Failed to allocate buffer for section filter handler (device=%d): ", deviceIndexM);
Start();
#endif
}
cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
{
debug("cSatipSectionFilterHandler::%s(%d)", __FUNCTION__, deviceIndexM);
#ifdef USE_THREADED_SECTIONFILTER
// Stop thread
if (Running())
Cancel(3);
DELETE_POINTER(ringBufferM);
#endif
// Destroy all filters
cMutexLock MutexLock(&mutexM);
@@ -262,13 +266,22 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
Delete(i);
}
#ifdef USE_THREADED_SECTIONFILTER
void cSatipSectionFilterHandler::Action(void)
{
debug("cSatipSectionFilterHandler::%s(%d): entering", __FUNCTION__, deviceIndexM);
bool processed = false;
// Do the thread loop
while (Running()) {
// Send demuxed section packets through all filters
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;
@@ -304,7 +317,6 @@ void cSatipSectionFilterHandler::Action(void)
}
debug("cSatipSectionFilterHandler::%s(%d): exiting", __FUNCTION__, deviceIndexM);
}
#endif
cString cSatipSectionFilterHandler::GetInformation(void)
{
@@ -405,35 +417,10 @@ int cSatipSectionFilterHandler::GetPid(int handleP)
void cSatipSectionFilterHandler::Write(uchar *bufferP, int lengthP)
{
//debug("cSatipSectionFilterHandler::%s(%d): length=%d", __FUNCTION__, deviceIndexM, lengthP);
#ifdef USE_THREADED_SECTIONFILTER
// Fill up the buffer
if (ringBufferM) {
int len = ringBufferM->Put(bufferP, lengthP);
if (len != lengthP)
ringBufferM->ReportOverflow(lengthP - len);
}
#else
// Lock
cMutexLock MutexLock(&mutexM);
uchar *p = bufferP;
int len = lengthP;
// Process TS packets through all filters
while (p && (len >= TS_SIZE)) {
if (*p != TS_SYNC_BYTE) {
for (int i = 1; i < len; ++i) {
if (p[i] == TS_SYNC_BYTE) {
p += i;
len -= i;
break;
}
}
}
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i])
filtersM[i]->Process(p);
}
p += TS_SIZE;
len -= TS_SIZE;
}
#endif
}

View File

@@ -8,21 +8,16 @@
#ifndef __SATIP_SECTIONFILTER_H
#define __SATIP_SECTIONFILTER_H
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif // __FreeBSD__
#include <vdr/device.h>
#include "common.h"
#include "statistics.h"
#define USE_THREADED_SECTIONFILTER
class cSatipSectionFilter : public cSatipSectionStatistics {
private:
enum {
eWriteMaxRetries = 20,
eDmxMaxFilterSize = 18,
eDmxMaxSectionCount = 64,
eDmxMaxSectionSize = 4096,
eDmxMaxSectionFeedSize = (eDmxMaxSectionSize + TS_SIZE)
};
@@ -38,6 +33,7 @@ private:
uint16_t tsFeedpM;
uint16_t pidM;
cRingBufferFrame *ringBufferM;
int deviceIndexM;
int socketM[2];
@@ -59,23 +55,17 @@ public:
cSatipSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP);
virtual ~cSatipSectionFilter();
void Process(const uint8_t* dataP);
bool Send(void);
int GetFd(void) { return socketM[0]; }
uint16_t GetPid(void) const { return pidM; }
};
#ifdef USE_THREADED_SECTIONFILTER
class cSatipSectionFilterHandler : public cThread {
protected:
virtual void Action(void);
private:
cRingBufferLinear *ringBufferM;
#else
class cSatipSectionFilterHandler {
#endif
private:
enum {
eMaxSecFilterCount = 32
};
cRingBufferLinear *ringBufferM;
cMutex mutexM;
int deviceIndexM;
cSatipSectionFilter *filtersM[eMaxSecFilterCount];
@@ -83,6 +73,9 @@ private:
bool Delete(unsigned int indexP);
bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const;
protected:
virtual void Action(void);
public:
cSatipSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP);
virtual ~cSatipSectionFilterHandler();

View File

@@ -83,7 +83,7 @@ size_t cSatipTuner::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void
int timeout = -1;
char *session = NULL;
if (sscanf(r, "Session:%m[^;];timeout=%11d", &session, &timeout) == 2)
obj->SetSessionTimeout(skipspace(session), (timeout - 1) * 1000);
obj->SetSessionTimeout(skipspace(session), timeout * 1000);
else if (sscanf(r, "Session:%m[^;]", &session) == 1)
obj->SetSessionTimeout(skipspace(session));
FREE_POINTER(session);

View File

@@ -26,10 +26,10 @@
class cSatipTuner : public cThread, public cSatipTunerStatistics {
private:
enum {
eConnectTimeoutMs = 1500, // in milliseconds
ePidUpdateIntervalMs = 100, // in milliseconds
eReConnectTimeoutMs = 5000, // in milliseconds
eMinKeepAliveIntervalMs = 300000 // in milliseconds
eConnectTimeoutMs = 1500, // in milliseconds
ePidUpdateIntervalMs = 100, // in milliseconds
eReConnectTimeoutMs = 5000, // in milliseconds
eMinKeepAliveIntervalMs = 30000 // in milliseconds
};
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);