mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Added mechanism to resize protocol read buffers on the fly.
This commit is contained in:
parent
e85dc10fea
commit
d4133a8888
5
config.c
5
config.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.c,v 1.3 2007/09/16 13:38:20 rahrenbe Exp $
|
||||
* $Id: config.c,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -16,6 +16,7 @@ cIptvConfig::cIptvConfig(void)
|
||||
tsBufferPrefillRatio(0),
|
||||
udpBufferSize(7),
|
||||
httpBufferSize(7),
|
||||
fileBufferSize(7)
|
||||
fileBufferSize(20),
|
||||
maxBufferSize(40) // must be bigger than protocol buffer sizes!
|
||||
{
|
||||
}
|
||||
|
4
config.h
4
config.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.h,v 1.3 2007/09/16 13:38:20 rahrenbe Exp $
|
||||
* $Id: config.h,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_CONFIG_H
|
||||
@ -20,6 +20,7 @@ protected:
|
||||
unsigned int udpBufferSize;
|
||||
unsigned int httpBufferSize;
|
||||
unsigned int fileBufferSize;
|
||||
unsigned int maxBufferSize;
|
||||
public:
|
||||
cIptvConfig();
|
||||
unsigned int GetTsBufferSize(void) { return tsBufferSize; }
|
||||
@ -27,6 +28,7 @@ public:
|
||||
unsigned int GetUdpBufferSize(void) { return udpBufferSize; }
|
||||
unsigned int GetHttpBufferSize(void) { return httpBufferSize; }
|
||||
unsigned int GetFileBufferSize(void) { return fileBufferSize; }
|
||||
unsigned int GetMaxBufferSize(void) { return maxBufferSize; }
|
||||
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
|
||||
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
|
||||
void SetUdpBufferSize(unsigned int Size) { udpBufferSize = Size; }
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolfile.c,v 1.6 2007/09/20 21:15:08 rahrenbe Exp $
|
||||
* $Id: protocolfile.c,v 1.7 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
@ -16,14 +16,13 @@
|
||||
#include "protocolfile.h"
|
||||
|
||||
cIptvProtocolFile::cIptvProtocolFile()
|
||||
: readBufferLen(TS_SIZE * IptvConfig.GetFileBufferSize()),
|
||||
fileActive(false)
|
||||
: fileActive(false)
|
||||
{
|
||||
debug("cIptvProtocolFile::cIptvProtocolFile(): readBufferLen=%d (%d)\n",
|
||||
readBufferLen, (readBufferLen / TS_SIZE));
|
||||
debug("cIptvProtocolFile::cIptvProtocolFile(): %d/%d packets\n",
|
||||
IptvConfig.GetFileBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
streamAddr = strdup("");
|
||||
// Allocate receive buffer
|
||||
readBuffer = MALLOC(unsigned char, readBufferLen);
|
||||
readBuffer = MALLOC(unsigned char, (TS_SIZE * IptvConfig.GetMaxBufferSize()));
|
||||
if (!readBuffer)
|
||||
error("ERROR: MALLOC() failed in ProtocolFile()");
|
||||
}
|
||||
@ -84,7 +83,7 @@ int cIptvProtocolFile::Read(unsigned char* *BufferAddr)
|
||||
// during the sleep and buffers are disposed. Check here that the plugin is
|
||||
// still active before accessing the buffers
|
||||
if (fileActive)
|
||||
return fread(readBuffer, sizeof(unsigned char), readBufferLen, fileStream);
|
||||
return fread(readBuffer, sizeof(unsigned char), (TS_SIZE * IptvConfig.GetFileBufferSize()), fileStream);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolfile.h,v 1.2 2007/09/16 14:47:01 ajhseppa Exp $
|
||||
* $Id: protocolfile.h,v 1.3 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLFILE_H
|
||||
@ -18,7 +18,6 @@ private:
|
||||
int streamPort;
|
||||
FILE* fileStream;
|
||||
unsigned char* readBuffer;
|
||||
unsigned int readBufferLen;
|
||||
bool fileActive;
|
||||
|
||||
private:
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolhttp.c,v 1.3 2007/09/19 17:14:03 rahrenbe Exp $
|
||||
* $Id: protocolhttp.c,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -22,15 +22,14 @@
|
||||
cIptvProtocolHttp::cIptvProtocolHttp()
|
||||
: streamPort(1234),
|
||||
socketDesc(-1),
|
||||
readBufferLen(TS_SIZE * IptvConfig.GetHttpBufferSize()),
|
||||
unicastActive(false)
|
||||
{
|
||||
debug("cIptvProtocolHttp::cIptvProtocolHttp(): readBufferLen=%d (%d)\n",
|
||||
readBufferLen, (readBufferLen / TS_SIZE));
|
||||
debug("cIptvProtocolHttp::cIptvProtocolHttp(): %d/%d packets\n",
|
||||
IptvConfig.GetHttpBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
streamAddr = strdup("");
|
||||
streamPath = strdup("/");
|
||||
// Allocate receive buffer
|
||||
readBuffer = MALLOC(unsigned char, readBufferLen);
|
||||
readBuffer = MALLOC(unsigned char, (TS_SIZE * IptvConfig.GetMaxBufferSize()));
|
||||
if (!readBuffer)
|
||||
error("ERROR: MALLOC() failed in ProtocolHttp()");
|
||||
}
|
||||
@ -238,8 +237,8 @@ int cIptvProtocolHttp::Read(unsigned char* *BufferAddr)
|
||||
// Check if data available
|
||||
else if (retval) {
|
||||
// Read data from socket
|
||||
return recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
||||
(struct sockaddr *)&sockAddr, &addrlen);
|
||||
return recvfrom(socketDesc, readBuffer, (TS_SIZE * IptvConfig.GetHttpBufferSize()),
|
||||
MSG_DONTWAIT, (struct sockaddr *)&sockAddr, &addrlen);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolhttp.h,v 1.2 2007/09/19 17:14:03 rahrenbe Exp $
|
||||
* $Id: protocolhttp.h,v 1.3 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLHTTP_H
|
||||
@ -19,7 +19,6 @@ private:
|
||||
int streamPort;
|
||||
int socketDesc;
|
||||
unsigned char* readBuffer;
|
||||
unsigned int readBufferLen;
|
||||
struct sockaddr_in sockAddr;
|
||||
bool unicastActive;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocoludp.c,v 1.5 2007/09/16 13:38:20 rahrenbe Exp $
|
||||
* $Id: protocoludp.c,v 1.6 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -21,14 +21,13 @@
|
||||
cIptvProtocolUdp::cIptvProtocolUdp()
|
||||
: streamPort(1234),
|
||||
socketDesc(-1),
|
||||
readBufferLen(TS_SIZE * IptvConfig.GetUdpBufferSize()),
|
||||
mcastActive(false)
|
||||
{
|
||||
debug("cIptvProtocolUdp::cIptvProtocolUdp(): readBufferLen=%d (%d)\n",
|
||||
readBufferLen, (readBufferLen / TS_SIZE));
|
||||
debug("cIptvProtocolUdp::cIptvProtocolUdp(): %d/%d packets\n",
|
||||
IptvConfig.GetUdpBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
streamAddr = strdup("");
|
||||
// Allocate receive buffer
|
||||
readBuffer = MALLOC(unsigned char, readBufferLen);
|
||||
readBuffer = MALLOC(unsigned char, (TS_SIZE * IptvConfig.GetMaxBufferSize()));
|
||||
if (!readBuffer)
|
||||
error("ERROR: MALLOC() failed in ProtocolUdp()");
|
||||
}
|
||||
@ -177,8 +176,8 @@ int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
|
||||
// Check if data available
|
||||
else if (retval) {
|
||||
// Read data from socket
|
||||
return recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
||||
(struct sockaddr *)&sockAddr, &addrlen);
|
||||
return recvfrom(socketDesc, readBuffer, (TS_SIZE * IptvConfig.GetUdpBufferSize()),
|
||||
MSG_DONTWAIT, (struct sockaddr *)&sockAddr, &addrlen);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocoludp.h,v 1.3 2007/09/15 21:27:00 rahrenbe Exp $
|
||||
* $Id: protocoludp.h,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLUDP_H
|
||||
@ -18,7 +18,6 @@ private:
|
||||
int streamPort;
|
||||
int socketDesc;
|
||||
unsigned char* readBuffer;
|
||||
unsigned int readBufferLen;
|
||||
struct sockaddr_in sockAddr;
|
||||
bool mcastActive;
|
||||
|
||||
|
10
setup.c
10
setup.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.c,v 1.7 2007/09/19 17:14:03 rahrenbe Exp $
|
||||
* $Id: setup.c,v 1.8 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -429,11 +429,11 @@ void cIptvPluginSetup::Setup(void)
|
||||
{
|
||||
int current = Current();
|
||||
Clear();
|
||||
Add(new cMenuEditIntItem(tr("TS buffer size [MB]"), &tsBufferSize, 2, 16));
|
||||
Add(new cMenuEditIntItem(tr("TS buffer size [MB]"), &tsBufferSize, 2, 16));
|
||||
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));
|
||||
Add(new cMenuEditIntItem(tr("UDP buffer size [packets]"), &udpBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
Add(new cMenuEditIntItem(tr("HTTP buffer size [packets]"), &httpBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
Add(new cMenuEditIntItem(tr("FILE buffer size [packets]"), &fileBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
SetCurrent(Get(current));
|
||||
Display();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user