From dc9f9f2b8636c8816c862f6f6cfbc9ea2a8b750e Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Sat, 5 Apr 2014 19:01:36 +0300 Subject: [PATCH] Removed unnecessary TS buffer settings. --- HISTORY | 1 + common.h | 2 ++ config.c | 4 +--- config.h | 6 ------ device.c | 31 +++++-------------------------- device.h | 6 ------ iptv.c | 6 +----- po/de_DE.po | 18 ------------------ po/fi_FI.po | 24 ------------------------ po/fr_FR.po | 24 ------------------------ po/it_IT.po | 26 +------------------------- po/nl_NL.po | 24 ------------------------ po/ru_RU.po | 18 ------------------ protocolcurl.c | 5 ++--- setup.c | 12 ------------ setup.h | 2 -- statistics.c | 2 +- 17 files changed, 14 insertions(+), 197 deletions(-) diff --git a/HISTORY b/HISTORY index e0ffc69..689f479 100644 --- a/HISTORY +++ b/HISTORY @@ -251,3 +251,4 @@ VDR Plugin 'iptv' Revision History 2014-04-12: Version 2.1.3 - Updated the section filtering options. +- Removed unnecessary TS buffer settings. diff --git a/common.h b/common.h index c034940..450f53a 100644 --- a/common.h +++ b/common.h @@ -24,6 +24,8 @@ #define ELEMENTS(x) (sizeof(x) / sizeof(x[0])) +#define IPTV_BUFFER_SIZE MEGABYTE(1) + #define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr" #define IPTV_SOURCE_CHARACTER 'I' diff --git a/config.c b/config.c index ac9cdf4..6a5e7b2 100644 --- a/config.c +++ b/config.c @@ -10,9 +10,7 @@ cIptvConfig IptvConfig; cIptvConfig::cIptvConfig(void) -: tsBufferSizeM(2), - tsBufferPrefillRatioM(0), - protocolBasePortM(4321), +: protocolBasePortM(4321), useBytesM(1), sectionFilteringM(1) { diff --git a/config.h b/config.h index 37fa317..e13318a 100644 --- a/config.h +++ b/config.h @@ -14,8 +14,6 @@ class cIptvConfig { private: - unsigned int tsBufferSizeM; - unsigned int tsBufferPrefillRatioM; unsigned int protocolBasePortM; unsigned int useBytesM; unsigned int sectionFilteringM; @@ -25,8 +23,6 @@ private: public: cIptvConfig(); - unsigned int GetTsBufferSize(void) const { return tsBufferSizeM; } - unsigned int GetTsBufferPrefillRatio(void) const { return tsBufferPrefillRatioM; } unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; } unsigned int GetUseBytes(void) const { return useBytesM; } unsigned int GetSectionFiltering(void) const { return sectionFilteringM; } @@ -34,8 +30,6 @@ public: const char *GetResourceDirectory(void) const { return resourceDirectoryM; } unsigned int GetDisabledFiltersCount(void) const; int GetDisabledFilters(unsigned int indexP) const; - void SetTsBufferSize(unsigned int sizeP) { tsBufferSizeM = sizeP; } - void SetTsBufferPrefillRatio(unsigned int ratioP) { tsBufferPrefillRatioM = ratioP; } void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; } void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; } void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; } diff --git a/device.c b/device.c index 04373ec..1ca7043 100644 --- a/device.c +++ b/device.c @@ -22,7 +22,7 @@ cIptvDevice::cIptvDevice(unsigned int indexP) pidScanEnabledM(false), channelM() { - unsigned int bufsize = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()); + unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE; bufsize -= (bufsize % TS_SIZE); isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex()); tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false, @@ -32,7 +32,6 @@ cIptvDevice::cIptvDevice(unsigned int indexP) tsBufferM->SetIoThrottle(); pIptvStreamerM = new cIptvStreamer(*this, tsBufferM->Free()); } - ResetBuffering(); pUdpProtocolM = new cIptvProtocolUdp(); pCurlProtocolM = new cIptvProtocolCurl(); pHttpProtocolM = new cIptvProtocolHttp(); @@ -305,7 +304,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP) { - debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP->pid, typeP, onP); + debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP ? handleP->pid : -1, typeP, onP); if (pIptvStreamerM && handleP) return pIptvStreamerM->SetPid(handleP->pid, typeP, onP); return true; @@ -337,7 +336,6 @@ bool cIptvDevice::OpenDvr(void) debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); isPacketDeliveredM = false; tsBufferM->Clear(); - ResetBuffering(); if (pIptvStreamerM) pIptvStreamerM->Open(); if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering()) @@ -363,7 +361,7 @@ void cIptvDevice::CloseDvr(void) bool cIptvDevice::HasLock(int timeoutMsP) const { //debug("cIptvDevice::%s(%d): timeoutMs=%d", __FUNCTION__, deviceIndexM, timeoutMsP); - return (!IsBuffering()); + return (pIptvStreamerM && pIptvStreamerM->Active()); } bool cIptvDevice::HasInternalCam(void) @@ -372,25 +370,6 @@ bool cIptvDevice::HasInternalCam(void) return false; } -void cIptvDevice::ResetBuffering(void) -{ - debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); - // Pad prefill to multiple of TS_SIZE - tsBufferPrefillM = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) * - IptvConfig.GetTsBufferPrefillRatio() / 100; - tsBufferPrefillM -= (tsBufferPrefillM % TS_SIZE); -} - -bool cIptvDevice::IsBuffering(void) const -{ - //debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); - if (tsBufferPrefillM && tsBufferM && tsBufferM->Available() < tsBufferPrefillM) - return true; - else - tsBufferPrefillM = 0; - return false; -} - void cIptvDevice::WriteData(uchar *bufferP, int lengthP) { //debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); @@ -420,7 +399,7 @@ unsigned int cIptvDevice::CheckData(void) uchar *cIptvDevice::GetData(int *availableP) { //debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); - if (isOpenDvrM && tsBufferM && !IsBuffering()) { + if (isOpenDvrM && tsBufferM) { int count = 0; if (isPacketDeliveredM) SkipData(TS_SIZE); @@ -434,7 +413,7 @@ uchar *cIptvDevice::GetData(int *availableP) } } tsBufferM->Del(count); - error("Skipped %d bytes to sync on TS packet", count); + info("Skipped %d bytes to sync on TS packet", count); return NULL; } isPacketDeliveredM = true; diff --git a/device.h b/device.h index a002a8e..ce254b8 100644 --- a/device.h +++ b/device.h @@ -40,7 +40,6 @@ private: bool sidScanEnabledM; bool pidScanEnabledM; cRingBufferLinear *tsBufferM; - mutable int tsBufferPrefillM; cChannel channelM; cIptvProtocolUdp *pUdpProtocolM; cIptvProtocolCurl *pCurlProtocolM; @@ -69,11 +68,6 @@ private: cString GetPidsInformation(void); cString GetFiltersInformation(void); - // for channel parsing & buffering -private: - void ResetBuffering(void); - bool IsBuffering(void) const; - // for channel info public: virtual cString DeviceType(void) const; diff --git a/iptv.c b/iptv.c index 98dd312..2c00080 100644 --- a/iptv.c +++ b/iptv.c @@ -192,11 +192,7 @@ bool cPluginIptv::SetupParse(const char *nameP, const char *valueP) { debug("cPluginIptv::%s()", __FUNCTION__); // Parse your own setup parameters and store their values. - if (!strcasecmp(nameP, "TsBufferSize")) - IptvConfig.SetTsBufferSize(atoi(valueP)); - else if (!strcasecmp(nameP, "TsBufferPrefill")) - IptvConfig.SetTsBufferPrefillRatio(atoi(valueP)); - else if (!strcasecmp(nameP, "ExtProtocolBasePort")) + if (!strcasecmp(nameP, "ExtProtocolBasePort")) IptvConfig.SetProtocolBasePort(atoi(valueP)); else if (!strcasecmp(nameP, "SectionFiltering")) IptvConfig.SetSectionFiltering(atoi(valueP)); diff --git a/po/de_DE.po b/po/de_DE.po index 5dad05e..f432c5f 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -53,24 +53,6 @@ msgstr "Bits/Bytes" msgid "IPTV information not available!" msgstr "IPTV Informationen nicht verfügbar!" -msgid "TS buffer size [MB]" -msgstr "TS Puffergröße [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" - -msgid "TS buffer prefill ratio [%]" -msgstr "TS Puffer-Preload [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" - msgid "Protocol base port" msgstr "Protokoll Basisport" diff --git a/po/fi_FI.po b/po/fi_FI.po index e83cbeb..e211c22 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -52,30 +52,6 @@ msgstr "Bitit/tavut" msgid "IPTV information not available!" msgstr "IPTV-tietoja ei saatavilla!" -msgid "TS buffer size [MB]" -msgstr "TS-puskurin koko [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" -"Määritä rengaspuskurin koko TS-lähetteelle megatavuina.\n" -"\n" -"Pienempi rengaspuskuri vähentää muistinkulutusta, mutta on virhealttiimpi puskurin ylivuodolle." - -msgid "TS buffer prefill ratio [%]" -msgstr "TS-puskurin esitäyttöaste [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" -"Määrittele TS-rengaspuskurin esitäyttöaste, jonka jälkeen lähetettä aletaan siirtämään eteenpäin VDR:lle.\n" -"\n" -"Puskurin esitäyttö parantaa suoratoistoa hitailla ja epäluotettavilla yhteyksillä." - msgid "Protocol base port" msgstr "Protokollan perusportti" diff --git a/po/fr_FR.po b/po/fr_FR.po index dbb6d26..01d900d 100644 --- a/po/fr_FR.po +++ b/po/fr_FR.po @@ -54,30 +54,6 @@ msgstr "Bits/Bytes" msgid "IPTV information not available!" msgstr "Information sur IPTV non disponible !" -msgid "TS buffer size [MB]" -msgstr "Taille du buffer TS [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" -"Définit la taille du ringbuffer pour le transport du flux en megabytes.\n" -"\n" -"Une taille plus petite taille aide la consommation de mémoire, mais c'est sujet à plus de débordement de tampon." - -msgid "TS buffer prefill ratio [%]" -msgstr "Taux du buffer de pré-remplissage TS [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" -"Définit le ratio de pré-remplissage du ringbuffer pour le transport du flux avant transfert dans VDR.\n" -"\n" -"Cette option est utile si le streaming est sur une connexion lente ou peu fiables." - msgid "Protocol base port" msgstr "Port de base du protocole" diff --git a/po/it_IT.po b/po/it_IT.po index 98dd2f3..244da75 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-iptv 2.1.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-12 04:12+0300\n" +"POT-Creation-Date: 2014-04-12 04:12+0200\n" "PO-Revision-Date: 2014-04-12 04:12+0200\n" "Last-Translator: Diego Pierotto \n" "Language-Team: Italian \n" @@ -53,30 +53,6 @@ msgstr "Bits/bytes" msgid "IPTV information not available!" msgstr "Informazione IPTV non disponibile!" -msgid "TS buffer size [MB]" -msgstr "Dimensione buffer TS [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" -"Definisci una dimensione del buffer in MB per i flussi di trasporto.\n" -"\n" -"Dimensioni più piccole aiutano il consumo di memoria, ma sono più inclini a generare buffer overflows." - -msgid "TS buffer prefill ratio [%]" -msgstr "Riempimento buffer TS [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" -"Definisci un rapporto di riempimento del buffer per i flussi di trasporto prima che i dati siano trasferiti a VDR.\n" -"\n" -"Questo è utile se si trasmette dati su una connessione lenta oppure inaffidabile." - msgid "Protocol base port" msgstr "Porta base protocollo" diff --git a/po/nl_NL.po b/po/nl_NL.po index fbe14eb..c284c01 100644 --- a/po/nl_NL.po +++ b/po/nl_NL.po @@ -53,30 +53,6 @@ msgstr "Bits/Bytes" msgid "IPTV information not available!" msgstr "IPTV informatie niet beschikbaar!" -msgid "TS buffer size [MB]" -msgstr "TS buffergrootte [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" -"Stel de grootte van de ringbuffer vast voor transportstreams in megabytes.\n" -"\n" -"Bij lage waarden zapt VDR sneller maar kunnen leiden tot bufferoverschreidingen en dus dropouts." - -msgid "TS buffer prefill ratio [%]" -msgstr "TS buffer-preload [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" -"Stel een 'prefil ratio' in voor de ringbuffer voor transportstreams voor de data naar VDR wordt verstuurd.\n" -"\n" -"Dit is aan te bevelen bij onbetrouwbare of langzame verbindingen." - msgid "Protocol base port" msgstr "Protocol basispoort" diff --git a/po/ru_RU.po b/po/ru_RU.po index 68d9731..14ed512 100644 --- a/po/ru_RU.po +++ b/po/ru_RU.po @@ -54,24 +54,6 @@ msgstr "Биты / байт" msgid "IPTV information not available!" msgstr "IPTV информация отсутствует!" -msgid "TS buffer size [MB]" -msgstr "Размер TS буфера [MB]" - -msgid "" -"Define a ringbuffer size for transport streams in megabytes.\n" -"\n" -"Smaller sizes help memory consumption, but are more prone to buffer overflows." -msgstr "" - -msgid "TS buffer prefill ratio [%]" -msgstr "Предварительный буфер TS [%]" - -msgid "" -"Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n" -"\n" -"This is useful if streaming media over a slow or unreliable connection." -msgstr "" - msgid "Protocol base port" msgstr "Базисный порт протокола" diff --git a/protocolcurl.c b/protocolcurl.c index d7832f7..fc42429 100644 --- a/protocolcurl.c +++ b/protocolcurl.c @@ -31,8 +31,7 @@ cIptvProtocolCurl::cIptvProtocolCurl() handleM(NULL), multiM(NULL), headerListM(NULL), - ringBufferM(new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()), - 7 * TS_SIZE, false, "IPTV CURL")), + ringBufferM(new cRingBufferLinear(IPTV_BUFFER_SIZE, 7 * TS_SIZE, false, "IPTV CURL")), rtspControlM(""), modeM(eModeUnknown), timeoutM(), @@ -522,7 +521,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP) // Use 20% threshold before continuing to filling up the buffer. mutexM.Lock(); - if (pausedM && (ringBufferM->Available() < (MEGABYTE(IptvConfig.GetTsBufferSize()) / 5))) { + if (pausedM && (ringBufferM->Available() < (IPTV_BUFFER_SIZE / 5))) { debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__, ringBufferM->Free(), ringBufferM->Available()); pausedM = false; diff --git a/setup.c b/setup.c index 2da9164..b7f84a3 100644 --- a/setup.c +++ b/setup.c @@ -113,8 +113,6 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP) cIptvPluginSetup::cIptvPluginSetup() { debug("cIptvPluginSetup::%s()", __FUNCTION__); - tsBufferSizeM = IptvConfig.GetTsBufferSize(); - tsBufferPrefillM = IptvConfig.GetTsBufferPrefillRatio(); protocolBasePortM = IptvConfig.GetProtocolBasePort(); sectionFilteringM = IptvConfig.GetSectionFiltering(); numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount(); @@ -136,12 +134,6 @@ void cIptvPluginSetup::Setup(void) Clear(); helpM.Clear(); - Add(new cMenuEditIntItem(tr("TS buffer size [MB]"), &tsBufferSizeM, 1, 4)); - helpM.Append(tr("Define a ringbuffer size for transport streams in megabytes.\n\nSmaller sizes help memory consumption, but are more prone to buffer overflows.")); - - Add(new cMenuEditIntItem(tr("TS buffer prefill ratio [%]"), &tsBufferPrefillM, 0, 40)); - helpM.Append(tr("Define a prefill ratio of the ringbuffer for transport streams before data is transferred to VDR.\n\nThis is useful if streaming media over a slow or unreliable connection.")); - Add(new cMenuEditIntItem(tr("Protocol base port"), &protocolBasePortM, 0, 0xFFFF - MAXDEVICES * 2)); helpM.Append(tr("Define a base port used by CURL/EXT protocol.\n\nThe port range is defined by the number of IPTV devices. This setting sets the port which is listened for connections from external applications when using the CURL/EXT protocol.")); @@ -217,14 +209,10 @@ void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP) void cIptvPluginSetup::Store(void) { // Store values into setup.conf - SetupStore("TsBufferSize", tsBufferSizeM); - SetupStore("TsBufferPrefill", tsBufferPrefillM); SetupStore("ExtProtocolBasePort", protocolBasePortM); SetupStore("SectionFiltering", sectionFilteringM); StoreFilters("DisabledFilters", disabledFilterIndexesM); // Update global config - IptvConfig.SetTsBufferSize(tsBufferSizeM); - IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefillM); IptvConfig.SetProtocolBasePort(protocolBasePortM); IptvConfig.SetSectionFiltering(sectionFilteringM); for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) diff --git a/setup.h b/setup.h index 3ebb04c..bbc9ed6 100644 --- a/setup.h +++ b/setup.h @@ -15,8 +15,6 @@ class cIptvPluginSetup : public cMenuSetupPage { private: - int tsBufferSizeM; - int tsBufferPrefillM; int protocolBasePortM; int sectionFilteringM; int numDisabledFiltersM; diff --git a/statistics.c b/statistics.c index 4b86feb..139cd3b 100644 --- a/statistics.c +++ b/statistics.c @@ -192,7 +192,7 @@ cString cIptvBufferStatistics::GetBufferStatistic() uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ timerM.Set(); long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L; - long totalSpace = MEGABYTE(IptvConfig.GetTsBufferSize()); + long totalSpace = IPTV_BUFFER_SIZE; float percentage = (float)((float)usedSpaceM / (float)totalSpace * 100.0); long totalKilos = totalSpace / KILOBYTE(1); long usedKilos = usedSpaceM / KILOBYTE(1);