Added a setup option for buffer prefill ratio and fixed protocol Read().

This commit is contained in:
Rolf Ahrenberg 2007-09-15 21:27:00 +00:00
parent bc817a0604
commit cb87392299
11 changed files with 48 additions and 20 deletions

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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: <vdr@linuxtv.org>\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 [%]"

View File

@ -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;

View File

@ -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 <sys/types.h>
@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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:

View File

@ -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 <vdr/thread.h>
@ -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);