1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Added new setup options.

This commit is contained in:
Rolf Ahrenberg 2007-09-16 13:38:20 +00:00
parent 026e730c81
commit b6aabba854
10 changed files with 110 additions and 63 deletions

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: config.c,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ * $Id: config.c,v 1.3 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -12,7 +12,10 @@
cIptvConfig IptvConfig; cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void) cIptvConfig::cIptvConfig(void)
: bufferSizeMB(8), : tsBufferSize(8),
bufferPrefillRatio(0) tsBufferPrefillRatio(0),
udpBufferSize(7),
httpBufferSize(7),
fileBufferSize(7)
{ {
} }

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: config.h,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ * $Id: config.h,v 1.3 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#ifndef __IPTV_CONFIG_H #ifndef __IPTV_CONFIG_H
@ -15,14 +15,23 @@
class cIptvConfig class cIptvConfig
{ {
protected: protected:
unsigned int bufferSizeMB; unsigned int tsBufferSize;
unsigned int bufferPrefillRatio; unsigned int tsBufferPrefillRatio;
unsigned int udpBufferSize;
unsigned int httpBufferSize;
unsigned int fileBufferSize;
public: public:
cIptvConfig(); cIptvConfig();
unsigned int GetBufferSizeMB(void) { return bufferSizeMB; } unsigned int GetTsBufferSize(void) { return tsBufferSize; }
unsigned int GetBufferPrefillRatio(void) { return bufferPrefillRatio; } unsigned int GetTsBufferPrefillRatio(void) { return tsBufferPrefillRatio; }
void SetBufferSizeMB(unsigned int Size) { bufferSizeMB = Size; } unsigned int GetUdpBufferSize(void) { return udpBufferSize; }
void SetBufferPrefillRatio(unsigned int Ratio) { bufferPrefillRatio = Ratio; } unsigned int GetHttpBufferSize(void) { return httpBufferSize; }
unsigned int GetFileBufferSize(void) { return fileBufferSize; }
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
void SetUdpBufferSize(unsigned int Size) { udpBufferSize = Size; }
void SetHttpBufferSize(unsigned int Size) { httpBufferSize = Size; }
void SetFileBufferSize(unsigned int Size) { fileBufferSize = Size; }
}; };
extern cIptvConfig IptvConfig; extern cIptvConfig IptvConfig;

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: device.c,v 1.19 2007/09/16 13:11:19 rahrenbe Exp $ * $Id: device.c,v 1.20 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -23,18 +23,17 @@ cIptvDevice::cIptvDevice(unsigned int Index)
mutex() mutex()
{ {
debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex); debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex);
tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetBufferSizeMB()), tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
(TS_SIZE * 2), false, "IPTV"); (TS_SIZE * 2), false, "IPTV");
tsBuffer->SetTimeouts(100, 100); tsBuffer->SetTimeouts(100, 100);
// pad prefill to multiple of TS_SIZE // pad prefill to multiple of TS_SIZE
tsBufferPrefill = MEGABYTE(IptvConfig.GetBufferSizeMB()) * tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
IptvConfig.GetBufferPrefillRatio() / 100; IptvConfig.GetTsBufferPrefillRatio() / 100;
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE); tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
//debug("Buffer=%d Prefill=%d\n", MEGABYTE(IptvConfig.GetBufferSizeMB()), tsBufferPrefill); //debug("Buffer=%d Prefill=%d\n", MEGABYTE(IptvConfig.GetTsBufferSize()), tsBufferPrefill);
pUdpProtocol = new cIptvProtocolUdp(); pUdpProtocol = new cIptvProtocolUdp();
pHttpProtocol = new cIptvProtocolHttp(); pHttpProtocol = new cIptvProtocolHttp();
pFileProtocol = new cIptvProtocolFile(); pFileProtocol = new cIptvProtocolFile();
//pRtspProtocol = new cIptvProtocolRtsp();
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex); pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
StartSectionHandler(); StartSectionHandler();
} }
@ -92,18 +91,12 @@ cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvPro
*Protocol = pHttpProtocol; *Protocol = pHttpProtocol;
return addr; return addr;
} }
//else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, IpPort) == 5) { else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, IpPort) == 5) {
// cString addr(loc, true); cString addr(loc, true);
// free(loc); free(loc);
// *Protocol = pFileProtocol; *Protocol = pFileProtocol;
// return addr; return addr;
// } }
//else if (sscanf(Param, "IPTV|RTSP|%a[^|]|%u", &loc, IpPort) == 5) {
// cString addr(loc, true);
// free(loc);
// *Protocol = pRtspProtocol;
// return addr;
// }
return NULL; return NULL;
} }
@ -151,8 +144,8 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
return false; return false;
} }
// pad prefill to multiple of TS_SIZE // pad prefill to multiple of TS_SIZE
tsBufferPrefill = MEGABYTE(IptvConfig.GetBufferSizeMB()) * tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
IptvConfig.GetBufferPrefillRatio() / 100; IptvConfig.GetTsBufferPrefillRatio() / 100;
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE); tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
pIptvStreamer->Set(addr, port, protocol); pIptvStreamer->Set(addr, port, protocol);
return true; return true;

16
iptv.c
View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: iptv.c,v 1.4 2007/09/15 23:58:23 rahrenbe Exp $ * $Id: iptv.c,v 1.5 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -154,10 +154,16 @@ bool cPluginIptv::SetupParse(const char *Name, const char *Value)
{ {
debug("cPluginIptv::SetupParse()\n"); debug("cPluginIptv::SetupParse()\n");
// Parse your own setup parameters and store their values. // Parse your own setup parameters and store their values.
if (!strcasecmp(Name, "BufferSize")) if (!strcasecmp(Name, "TsBufferSize"))
IptvConfig.SetBufferSizeMB(atoi(Value)); IptvConfig.SetTsBufferSize(atoi(Value));
else if (!strcasecmp(Name, "BufferPrefill")) else if (!strcasecmp(Name, "TsBufferPrefill"))
IptvConfig.SetBufferPrefillRatio(atoi(Value)); IptvConfig.SetTsBufferPrefillRatio(atoi(Value));
else if (!strcasecmp(Name, "UdpBufferSize"))
IptvConfig.SetUdpBufferSize(atoi(Value));
else if (!strcasecmp(Name, "HttpBufferSize"))
IptvConfig.SetHttpBufferSize(atoi(Value));
else if (!strcasecmp(Name, "FileBufferSize"))
IptvConfig.SetFileBufferSize(atoi(Value));
else else
return false; return false;
return true; return true;

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: VDR 1.5.7\n" "Project-Id-Version: VDR 1.5.7\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" "Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2007-09-15 23:45+0300\n" "POT-Creation-Date: 2007-09-16 16:35+0300\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n" "Last-Translator: Rolf Ahrenberg\n"
"Language-Team: <vdr@linuxtv.org>\n" "Language-Team: <vdr@linuxtv.org>\n"
@ -19,10 +19,22 @@ msgstr ""
msgid "Experiment the IPTV" msgid "Experiment the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma" msgstr "Koe IPTV:n ihmeellinen maailma"
#: setup.c:24 #: setup.c:28
msgid "Buffer size [MB]" msgid "TS buffer size [MB]"
msgstr "Puskurin koko [MB]" msgstr "TS-puskurin koko [MB]"
#: setup.c:25 #: setup.c:29
msgid "Buffer prefill ratio [%]" msgid "TS buffer prefill ratio [%]"
msgstr "Puskurin esitäyttöaste [%]" msgstr "TS-puskurin esitäyttöaste [%]"
#: setup.c:30
msgid "UDP buffer size [packets]"
msgstr "UDP-puskurin koko [pakettia]"
#: setup.c:31
msgid "HTTP buffer size [packets]"
msgstr "HTTP-puskurin koko [pakettia]"
#: setup.c:32
msgid "FILE buffer size [packets]"
msgstr "FILE-puskurin koko [pakettia]"

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocolfile.c,v 1.1 2007/09/16 12:18:15 ajhseppa Exp $ * $Id: protocolfile.c,v 1.2 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include <fcntl.h> #include <fcntl.h>
@ -12,14 +12,16 @@
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
#include "config.h"
#include "protocolfile.h" #include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile() cIptvProtocolFile::cIptvProtocolFile()
: fileDesc(-1), : fileDesc(-1),
readBufferLen(TS_SIZE * 7), readBufferLen(TS_SIZE * IptvConfig.GetFileBufferSize()),
fileActive(false) fileActive(false)
{ {
debug("cIptvProtocolFile::cIptvProtocolFile()\n"); debug("cIptvProtocolFile::cIptvProtocolFile(): readBufferLen=%d (%d)\n",
readBufferLen, (readBufferLen / TS_SIZE));
streamAddr = strdup(""); streamAddr = strdup("");
// Allocate receive buffer // Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen); readBuffer = MALLOC(unsigned char, readBufferLen);

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocolhttp.c,v 1.1 2007/09/16 09:38:01 ajhseppa Exp $ * $Id: protocolhttp.c,v 1.2 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -15,15 +15,17 @@
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
#include "config.h"
#include "protocolhttp.h" #include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp() cIptvProtocolHttp::cIptvProtocolHttp()
: streamPort(1234), : streamPort(1234),
socketDesc(-1), socketDesc(-1),
readBufferLen(TS_SIZE * 7), readBufferLen(TS_SIZE * IptvConfig.GetHttpBufferSize()),
unicastActive(false) unicastActive(false)
{ {
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n"); debug("cIptvProtocolHttp::cIptvProtocolHttp(): readBufferLen=%d (%d)\n",
readBufferLen, (readBufferLen / TS_SIZE));
streamAddr = strdup(""); streamAddr = strdup("");
// Allocate receive buffer // Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen); readBuffer = MALLOC(unsigned char, readBufferLen);

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: protocoludp.c,v 1.4 2007/09/15 23:58:23 rahrenbe Exp $ * $Id: protocoludp.c,v 1.5 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
@ -15,15 +15,17 @@
#include <vdr/device.h> #include <vdr/device.h>
#include "common.h" #include "common.h"
#include "config.h"
#include "protocoludp.h" #include "protocoludp.h"
cIptvProtocolUdp::cIptvProtocolUdp() cIptvProtocolUdp::cIptvProtocolUdp()
: streamPort(1234), : streamPort(1234),
socketDesc(-1), socketDesc(-1),
readBufferLen(TS_SIZE * 7), readBufferLen(TS_SIZE * IptvConfig.GetUdpBufferSize()),
mcastActive(false) mcastActive(false)
{ {
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n"); debug("cIptvProtocolUdp::cIptvProtocolUdp(): readBufferLen=%d (%d)\n",
readBufferLen, (readBufferLen / TS_SIZE));
streamAddr = strdup(""); streamAddr = strdup("");
// Allocate receive buffer // Allocate receive buffer
readBuffer = MALLOC(unsigned char, readBufferLen); readBuffer = MALLOC(unsigned char, readBufferLen);

33
setup.c
View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: setup.c,v 1.3 2007/09/15 23:58:23 rahrenbe Exp $ * $Id: setup.c,v 1.4 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -12,17 +12,24 @@
cIptvPluginSetup::cIptvPluginSetup(void) cIptvPluginSetup::cIptvPluginSetup(void)
{ {
bufferSize = IptvConfig.GetBufferSizeMB(); tsBufferSize = IptvConfig.GetTsBufferSize();
bufferPrefill = IptvConfig.GetBufferPrefillRatio(); tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
udpBufferSize = IptvConfig.GetUdpBufferSize();
httpBufferSize = IptvConfig.GetHttpBufferSize();
fileBufferSize = IptvConfig.GetFileBufferSize();
Setup(); Setup();
SetHelp(trVDR("Channels"), NULL, NULL, NULL);
} }
void cIptvPluginSetup::Setup(void) void cIptvPluginSetup::Setup(void)
{ {
int current = Current(); int current = Current();
Clear(); Clear();
Add(new cMenuEditIntItem(tr("Buffer size [MB]"), &bufferSize, 2, 16)); Add(new cMenuEditIntItem(tr("TS buffer size [MB]"), &tsBufferSize, 2, 16));
Add(new cMenuEditIntItem(tr("Buffer prefill ratio [%]"), &bufferPrefill, 0, 40)); Add(new cMenuEditIntItem(tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
Add(new cMenuEditIntItem(tr("UDP buffer size [packets]"), &udpBufferSize, 1, 14));
Add(new cMenuEditIntItem(tr("HTTP buffer size [packets]"), &httpBufferSize, 1, 14));
Add(new cMenuEditIntItem(tr("FILE buffer size [packets]"), &fileBufferSize, 1, 14));
SetCurrent(Get(current)); SetCurrent(Get(current));
Display(); Display();
} }
@ -35,8 +42,16 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
void cIptvPluginSetup::Store(void) void cIptvPluginSetup::Store(void)
{ {
SetupStore("BufferSize", bufferSize); // Store values into setup.conf
SetupStore("BufferPrefill", bufferPrefill); SetupStore("TsBufferSize", tsBufferSize);
IptvConfig.SetBufferSizeMB(bufferSize); SetupStore("TsBufferPrefill", tsBufferPrefill);
IptvConfig.SetBufferPrefillRatio(bufferPrefill); SetupStore("UdpBufferSize", udpBufferSize);
SetupStore("HttpBufferSize", httpBufferSize);
SetupStore("FileBufferSize", fileBufferSize);
// Update global config
IptvConfig.SetTsBufferSize(tsBufferSize);
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
IptvConfig.SetUdpBufferSize(udpBufferSize);
IptvConfig.SetHttpBufferSize(httpBufferSize);
IptvConfig.SetFileBufferSize(fileBufferSize);
} }

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: setup.h,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ * $Id: setup.h,v 1.3 2007/09/16 13:38:20 rahrenbe Exp $
*/ */
#ifndef __IPTV_SETUP_H #ifndef __IPTV_SETUP_H
@ -14,8 +14,11 @@
class cIptvPluginSetup : public cMenuSetupPage class cIptvPluginSetup : public cMenuSetupPage
{ {
private: private:
int bufferSize; int tsBufferSize;
int bufferPrefill; int tsBufferPrefill;
int udpBufferSize;
int httpBufferSize;
int fileBufferSize;
virtual void Setup(void); virtual void Setup(void);
protected: protected: