diff --git a/config.c b/config.c index c0fc9d3..32e911b 100644 --- a/config.c +++ b/config.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: config.c,v 1.1 2007/09/15 15:38:38 rahrenbe Exp $ + * $Id: config.c,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ */ #include "common.h" @@ -12,6 +12,7 @@ cIptvConfig IptvConfig; cIptvConfig::cIptvConfig(void) -: bufferSizeMB(8) +: bufferSizeMB(8), + bufferPrefillRatio(0) { } diff --git a/config.h b/config.h index c5bca69..bb96141 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: config.h,v 1.1 2007/09/15 15:38:38 rahrenbe Exp $ + * $Id: config.h,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ */ #ifndef __IPTV_CONFIG_H @@ -16,10 +16,13 @@ class cIptvConfig { protected: unsigned int bufferSizeMB; + unsigned int bufferPrefillRatio; public: cIptvConfig(); unsigned int GetBufferSizeMB(void) { return bufferSizeMB; } + unsigned int GetBufferPrefillRatio(void) { return bufferPrefillRatio; } void SetBufferSizeMB(unsigned int Size) { bufferSizeMB = Size; } + void SetBufferPrefillRatio(unsigned int Ratio) { bufferPrefillRatio = Ratio; } }; extern cIptvConfig IptvConfig; diff --git a/device.c b/device.c index d76e21d..671d8f5 100644 --- a/device.c +++ b/device.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: device.c,v 1.14 2007/09/15 17:15:37 rahrenbe Exp $ + * $Id: device.c,v 1.15 2007/09/15 21:27:00 rahrenbe Exp $ */ #include "common.h" @@ -23,8 +23,14 @@ cIptvDevice::cIptvDevice(unsigned int Index) mutex() { debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex); - tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetBufferSizeMB()), TS_SIZE * 2, false, "IPTV"); + tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetBufferSizeMB()), + (TS_SIZE * 2), false, "IPTV"); tsBuffer->SetTimeouts(100, 100); + // pad prefill to multiple of TS_SIZE + tsBufferPrefill = MEGABYTE(IptvConfig.GetBufferSizeMB()) * + IptvConfig.GetBufferPrefillRatio() / 100; + tsBufferPrefill -= (tsBufferPrefill % TS_SIZE); + //debug("Buffer=%dMB Prefill=%B\n", IptvConfig.GetBufferSizeMB(), tsBufferPrefill); pUdpProtocol = new cIptvProtocolUdp(); //pRtspProtocol = new cIptvProtocolRtsp(); //pHttpProtocol = new cIptvProtocolHttp(); @@ -65,7 +71,7 @@ cIptvDevice *cIptvDevice::Get(unsigned int DeviceIndex) { debug("cIptvDevice::Get()\n"); if ((DeviceIndex > 0) && (DeviceIndex <= IPTV_MAX_DEVICES)) - return IptvDevices[DeviceIndex - 1]; + return IptvDevices[DeviceIndex - 1]; return NULL; } @@ -132,6 +138,10 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) error("ERROR: Unrecognized IPTV channel settings: %s", Channel->Param()); return false; } + // pad prefill to multiple of TS_SIZE + tsBufferPrefill = MEGABYTE(IptvConfig.GetBufferSizeMB()) * + IptvConfig.GetBufferPrefillRatio() / 100; + tsBufferPrefill -= (tsBufferPrefill % TS_SIZE); pIptvStreamer->Set(addr, port, protocol); return true; } @@ -180,6 +190,10 @@ bool cIptvDevice::GetTSPacket(uchar *&Data) { int Count = 0; //debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex); + if (tsBufferPrefill && tsBuffer->Available() < tsBufferPrefill) + return false; + else + tsBufferPrefill = 0; if (isPacketDelivered) { tsBuffer->Del(TS_SIZE); isPacketDelivered = false; diff --git a/device.h b/device.h index 7b4216c..7a57c6d 100644 --- a/device.h +++ b/device.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: device.h,v 1.5 2007/09/14 16:10:44 rahrenbe Exp $ + * $Id: device.h,v 1.6 2007/09/15 21:27:00 rahrenbe Exp $ */ #ifndef __IPTV_DEVICE_H @@ -29,6 +29,7 @@ private: bool isPacketDelivered; bool isOpenDvr; cRingBufferLinear *tsBuffer; + int tsBufferPrefill; cIptvProtocolUdp *pUdpProtocol; //cIptvProtocolRtsp *pRtspProtocol; //cIptvProtocolHttp *pHttpProtocol; diff --git a/po/fi_FI.po b/po/fi_FI.po index aafbd25..f5d581d 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: VDR 1.5.7\n" "Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2007-09-15 18:35+0300\n" +"POT-Creation-Date: 2007-09-15 23:45+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: \n" @@ -19,6 +19,10 @@ msgstr "" msgid "Experiment the IPTV" msgstr "Koe IPTV:n ihmeellinen maailma" -#: setup.c:23 +#: setup.c:24 msgid "Buffer size [MB]" msgstr "Puskurin koko [MB]" + +#: setup.c:25 +msgid "Buffer prefill ratio [%]" +msgstr "Puskurin esitäyttöaste [%]" diff --git a/protocolif.h b/protocolif.h index 925aaac..a04c3c2 100644 --- a/protocolif.h +++ b/protocolif.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocolif.h,v 1.2 2007/09/15 20:33:15 rahrenbe Exp $ + * $Id: protocolif.h,v 1.3 2007/09/15 21:27:00 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLIF_H @@ -13,7 +13,7 @@ class cIptvProtocolIf { public: cIptvProtocolIf() {} virtual ~cIptvProtocolIf() {} - virtual int Read(unsigned char *Buffer) = 0; + virtual int Read(unsigned char* *BufferAddr) = 0; virtual bool Set(const char* Address, const int Port) = 0; virtual bool Open(void) = 0; virtual bool Close(void) = 0; diff --git a/protocoludp.c b/protocoludp.c index a1d8776..33322a1 100644 --- a/protocoludp.c +++ b/protocoludp.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocoludp.c,v 1.2 2007/09/15 20:33:15 rahrenbe Exp $ + * $Id: protocoludp.c,v 1.3 2007/09/15 21:27:00 rahrenbe Exp $ */ #include @@ -151,11 +151,11 @@ bool cIptvProtocolUdp::DropMulticast(void) return true; } -int cIptvProtocolUdp::Read(unsigned char *Buffer) +int cIptvProtocolUdp::Read(unsigned char* *BufferAddr) { //debug("cIptvProtocolUdp::Read()\n"); socklen_t addrlen = sizeof(sockAddr); - Buffer = readBuffer; + BufferAddr = &readBuffer; // Wait for data struct timeval tv; tv.tv_sec = 0; diff --git a/protocoludp.h b/protocoludp.h index 3de5cb7..f5356e3 100644 --- a/protocoludp.h +++ b/protocoludp.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocoludp.h,v 1.2 2007/09/15 20:33:15 rahrenbe Exp $ + * $Id: protocoludp.h,v 1.3 2007/09/15 21:27:00 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLUDP_H @@ -31,7 +31,7 @@ private: public: cIptvProtocolUdp(); virtual ~cIptvProtocolUdp(); - virtual int Read(unsigned char *Buffer); + virtual int Read(unsigned char* *BufferAddr); virtual bool Set(const char* Address, const int Port); virtual bool Open(void); virtual bool Close(void); diff --git a/setup.c b/setup.c index 1cc5fd3..976abe4 100644 --- a/setup.c +++ b/setup.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: setup.c,v 1.1 2007/09/15 15:38:38 rahrenbe Exp $ + * $Id: setup.c,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ */ #include "common.h" @@ -13,6 +13,7 @@ cIptvPluginSetup::cIptvPluginSetup(void) { bufferSize = IptvConfig.GetBufferSizeMB(); + bufferPrefill = IptvConfig.GetBufferPrefillRatio(); Setup(); } @@ -21,6 +22,7 @@ void cIptvPluginSetup::Setup(void) int current = Current(); Clear(); Add(new cMenuEditIntItem(tr("Buffer size [MB]"), &bufferSize, 0, 16)); + Add(new cMenuEditIntItem(tr("Buffer prefill ratio [%]"), &bufferPrefill, 0, 40)); SetCurrent(Get(current)); Display(); } @@ -34,5 +36,7 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key) void cIptvPluginSetup::Store(void) { SetupStore("BufferSize", bufferSize); + SetupStore("BufferPrefill", bufferPrefill); IptvConfig.SetBufferSizeMB(bufferSize); + IptvConfig.SetBufferPrefillRatio(bufferPrefill); } diff --git a/setup.h b/setup.h index 77add45..f90da95 100644 --- a/setup.h +++ b/setup.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: setup.h,v 1.1 2007/09/15 15:38:38 rahrenbe Exp $ + * $Id: setup.h,v 1.2 2007/09/15 21:27:00 rahrenbe Exp $ */ #ifndef __IPTV_SETUP_H @@ -15,6 +15,7 @@ class cIptvPluginSetup : public cMenuSetupPage { private: int bufferSize; + int bufferPrefill; virtual void Setup(void); protected: diff --git a/streamer.c b/streamer.c index 5b3890d..a7d0627 100644 --- a/streamer.c +++ b/streamer.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: streamer.c,v 1.12 2007/09/15 20:33:15 rahrenbe Exp $ + * $Id: streamer.c,v 1.13 2007/09/15 21:27:00 rahrenbe Exp $ */ #include @@ -35,7 +35,7 @@ void cIptvStreamer::Action(void) while (Running()) { if (ringBuffer && mutex && protocol) { unsigned char *buffer = NULL; - int length = protocol->Read(buffer); + int length = protocol->Read(&buffer); if (length >= 0) { mutex->Lock(); int p = ringBuffer->Put(buffer, length);