diff --git a/config.c b/config.c index 20bd584..f2bbade 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.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! { } diff --git a/config.h b/config.h index ce95d58..e0ab17e 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.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; } diff --git a/protocolfile.c b/protocolfile.c index 1616063..12cdf21 100644 --- a/protocolfile.c +++ b/protocolfile.c @@ -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 @@ -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; } diff --git a/protocolfile.h b/protocolfile.h index e43a81f..30a3065 100644 --- a/protocolfile.h +++ b/protocolfile.h @@ -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: diff --git a/protocolhttp.c b/protocolhttp.c index 546d44b..cce3d45 100644 --- a/protocolhttp.c +++ b/protocolhttp.c @@ -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 @@ -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; } diff --git a/protocolhttp.h b/protocolhttp.h index 25d8066..d5ae074 100644 --- a/protocolhttp.h +++ b/protocolhttp.h @@ -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; diff --git a/protocoludp.c b/protocoludp.c index 44b92e8..6ce7a2c 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.5 2007/09/16 13:38:20 rahrenbe Exp $ + * $Id: protocoludp.c,v 1.6 2007/09/20 21:45:51 rahrenbe Exp $ */ #include @@ -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; } diff --git a/protocoludp.h b/protocoludp.h index f5356e3..1dc0082 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.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; diff --git a/setup.c b/setup.c index bcf2c2d..54fce93 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.7 2007/09/19 17:14:03 rahrenbe Exp $ + * $Id: setup.c,v 1.8 2007/09/20 21:45:51 rahrenbe Exp $ */ #include @@ -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(); }