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

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. * 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" #include "common.h"
@ -12,6 +12,7 @@
cIptvConfig IptvConfig; cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void) 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. * 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 #ifndef __IPTV_CONFIG_H
@ -16,10 +16,13 @@ class cIptvConfig
{ {
protected: protected:
unsigned int bufferSizeMB; unsigned int bufferSizeMB;
unsigned int bufferPrefillRatio;
public: public:
cIptvConfig(); cIptvConfig();
unsigned int GetBufferSizeMB(void) { return bufferSizeMB; } unsigned int GetBufferSizeMB(void) { return bufferSizeMB; }
unsigned int GetBufferPrefillRatio(void) { return bufferPrefillRatio; }
void SetBufferSizeMB(unsigned int Size) { bufferSizeMB = Size; } void SetBufferSizeMB(unsigned int Size) { bufferSizeMB = Size; }
void SetBufferPrefillRatio(unsigned int Ratio) { bufferPrefillRatio = Ratio; }
}; };
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.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" #include "common.h"
@ -23,8 +23,14 @@ 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()), TS_SIZE * 2, false, "IPTV"); tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetBufferSizeMB()),
(TS_SIZE * 2), false, "IPTV");
tsBuffer->SetTimeouts(100, 100); 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(); pUdpProtocol = new cIptvProtocolUdp();
//pRtspProtocol = new cIptvProtocolRtsp(); //pRtspProtocol = new cIptvProtocolRtsp();
//pHttpProtocol = new cIptvProtocolHttp(); //pHttpProtocol = new cIptvProtocolHttp();
@ -65,7 +71,7 @@ cIptvDevice *cIptvDevice::Get(unsigned int DeviceIndex)
{ {
debug("cIptvDevice::Get()\n"); debug("cIptvDevice::Get()\n");
if ((DeviceIndex > 0) && (DeviceIndex <= IPTV_MAX_DEVICES)) if ((DeviceIndex > 0) && (DeviceIndex <= IPTV_MAX_DEVICES))
return IptvDevices[DeviceIndex - 1]; return IptvDevices[DeviceIndex - 1];
return NULL; return NULL;
} }
@ -132,6 +138,10 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->Param()); error("ERROR: Unrecognized IPTV channel settings: %s", Channel->Param());
return false; 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); pIptvStreamer->Set(addr, port, protocol);
return true; return true;
} }
@ -180,6 +190,10 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
{ {
int Count = 0; int Count = 0;
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex); //debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
if (tsBufferPrefill && tsBuffer->Available() < tsBufferPrefill)
return false;
else
tsBufferPrefill = 0;
if (isPacketDelivered) { if (isPacketDelivered) {
tsBuffer->Del(TS_SIZE); tsBuffer->Del(TS_SIZE);
isPacketDelivered = false; isPacketDelivered = false;

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.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 #ifndef __IPTV_DEVICE_H
@ -29,6 +29,7 @@ private:
bool isPacketDelivered; bool isPacketDelivered;
bool isOpenDvr; bool isOpenDvr;
cRingBufferLinear *tsBuffer; cRingBufferLinear *tsBuffer;
int tsBufferPrefill;
cIptvProtocolUdp *pUdpProtocol; cIptvProtocolUdp *pUdpProtocol;
//cIptvProtocolRtsp *pRtspProtocol; //cIptvProtocolRtsp *pRtspProtocol;
//cIptvProtocolHttp *pHttpProtocol; //cIptvProtocolHttp *pHttpProtocol;

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 18:35+0300\n" "POT-Creation-Date: 2007-09-15 23:45+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,6 +19,10 @@ msgstr ""
msgid "Experiment the IPTV" msgid "Experiment the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma" msgstr "Koe IPTV:n ihmeellinen maailma"
#: setup.c:23 #: setup.c:24
msgid "Buffer size [MB]" msgid "Buffer size [MB]"
msgstr "Puskurin koko [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. * 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 #ifndef __IPTV_PROTOCOLIF_H
@ -13,7 +13,7 @@ class cIptvProtocolIf {
public: public:
cIptvProtocolIf() {} cIptvProtocolIf() {}
virtual ~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 Set(const char* Address, const int Port) = 0;
virtual bool Open(void) = 0; virtual bool Open(void) = 0;
virtual bool Close(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. * 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> #include <sys/types.h>
@ -151,11 +151,11 @@ bool cIptvProtocolUdp::DropMulticast(void)
return true; return true;
} }
int cIptvProtocolUdp::Read(unsigned char *Buffer) int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
{ {
//debug("cIptvProtocolUdp::Read()\n"); //debug("cIptvProtocolUdp::Read()\n");
socklen_t addrlen = sizeof(sockAddr); socklen_t addrlen = sizeof(sockAddr);
Buffer = readBuffer; BufferAddr = &readBuffer;
// Wait for data // Wait for data
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;

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.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 #ifndef __IPTV_PROTOCOLUDP_H
@ -31,7 +31,7 @@ private:
public: public:
cIptvProtocolUdp(); cIptvProtocolUdp();
virtual ~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 Set(const char* Address, const int Port);
virtual bool Open(void); virtual bool Open(void);
virtual bool Close(void); virtual bool Close(void);

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.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" #include "common.h"
@ -13,6 +13,7 @@
cIptvPluginSetup::cIptvPluginSetup(void) cIptvPluginSetup::cIptvPluginSetup(void)
{ {
bufferSize = IptvConfig.GetBufferSizeMB(); bufferSize = IptvConfig.GetBufferSizeMB();
bufferPrefill = IptvConfig.GetBufferPrefillRatio();
Setup(); Setup();
} }
@ -21,6 +22,7 @@ void cIptvPluginSetup::Setup(void)
int current = Current(); int current = Current();
Clear(); Clear();
Add(new cMenuEditIntItem(tr("Buffer size [MB]"), &bufferSize, 0, 16)); Add(new cMenuEditIntItem(tr("Buffer size [MB]"), &bufferSize, 0, 16));
Add(new cMenuEditIntItem(tr("Buffer prefill ratio [%]"), &bufferPrefill, 0, 40));
SetCurrent(Get(current)); SetCurrent(Get(current));
Display(); Display();
} }
@ -34,5 +36,7 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
void cIptvPluginSetup::Store(void) void cIptvPluginSetup::Store(void)
{ {
SetupStore("BufferSize", bufferSize); SetupStore("BufferSize", bufferSize);
SetupStore("BufferPrefill", bufferPrefill);
IptvConfig.SetBufferSizeMB(bufferSize); 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. * 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 #ifndef __IPTV_SETUP_H
@ -15,6 +15,7 @@ class cIptvPluginSetup : public cMenuSetupPage
{ {
private: private:
int bufferSize; int bufferSize;
int bufferPrefill;
virtual void Setup(void); virtual void Setup(void);
protected: protected:

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: 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> #include <vdr/thread.h>
@ -35,7 +35,7 @@ void cIptvStreamer::Action(void)
while (Running()) { while (Running()) {
if (ringBuffer && mutex && protocol) { if (ringBuffer && mutex && protocol) {
unsigned char *buffer = NULL; unsigned char *buffer = NULL;
int length = protocol->Read(buffer); int length = protocol->Read(&buffer);
if (length >= 0) { if (length >= 0) {
mutex->Lock(); mutex->Lock();
int p = ringBuffer->Put(buffer, length); int p = ringBuffer->Put(buffer, length);