diff --git a/README b/README index 67e2d73..a5f1695 100644 --- a/README +++ b/README @@ -124,6 +124,10 @@ Notes: - The following section filters are recommended to be disabled: "NIT (0x40)", "SDT (0x42)", "TDT (0x70)" +- The EXT protocol listens UDP packets from localhost. The default listen + port base number is 4321 and it can be configured via a commandline + switch. The port range is defined by the number of IPTV devices (max. 8). + Acknowledgements: - The IPTV section filtering code is derived from Linux kernel. diff --git a/config.c b/config.c index 424cf7f..e47d029 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.15 2007/10/08 23:51:58 rahrenbe Exp $ + * $Id: config.c,v 1.16 2007/10/19 22:18:55 rahrenbe Exp $ */ #include "config.h" @@ -16,7 +16,8 @@ cIptvConfig::cIptvConfig(void) tsBufferPrefillRatio(0), useBytes(1), sectionFiltering(1), - sidScanning(1) + sidScanning(1), + extListenPortBase(4321) { for (unsigned int i = 0; i < sizeof(disabledFilters); ++i) disabledFilters[i] = -1; diff --git a/config.h b/config.h index 8d93b36..c05d394 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.13 2007/10/08 23:51:58 rahrenbe Exp $ + * $Id: config.h,v 1.14 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_CONFIG_H @@ -22,6 +22,7 @@ protected: unsigned int useBytes; unsigned int sectionFiltering; unsigned int sidScanning; + unsigned int extListenPortBase; int disabledFilters[SECTION_FILTER_TABLE_SIZE]; public: @@ -32,6 +33,7 @@ public: unsigned int GetUseBytes(void) { return useBytes; } unsigned int GetSectionFiltering(void) { return sectionFiltering; } unsigned int GetSidScanning(void) { return sidScanning; } + unsigned int GetExtListenPortBase(void) { return extListenPortBase; } unsigned int GetDisabledFiltersCount(void); int GetDisabledFilters(unsigned int Index); void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; } @@ -39,6 +41,7 @@ public: void SetUseBytes(unsigned int On) { useBytes = On; } void SetSectionFiltering(unsigned int On) { sectionFiltering = On; } void SetSidScanning(unsigned int On) { sidScanning = On; } + void SetExtListenPortBase(unsigned int PortNumber) { extListenPortBase = PortNumber; } void SetDisabledFilters(unsigned int Index, int Number); }; diff --git a/device.c b/device.c index 19fa558..7d1f32e 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.70 2007/10/19 21:36:27 rahrenbe Exp $ + * $Id: device.c,v 1.71 2007/10/19 22:18:55 rahrenbe Exp $ */ #include "config.h" @@ -225,7 +225,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam()); return false; } - pIptvStreamer->Set(location, parameter, protocol); + pIptvStreamer->Set(location, parameter, deviceIndex, protocol); if (pSidScanner && IptvConfig.GetSectionFiltering() && IptvConfig.GetSidScanning()) pSidScanner->SetChannel(Channel); return true; diff --git a/iptv.c b/iptv.c index c8bb1ec..5c2f770 100644 --- a/iptv.c +++ b/iptv.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: iptv.c,v 1.21 2007/10/15 21:03:45 rahrenbe Exp $ + * $Id: iptv.c,v 1.22 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -66,7 +66,8 @@ const char *cPluginIptv::CommandLineHelp(void) { debug("cPluginIptv::CommandLineHelp()\n"); // Return a string that describes all known command line options. - return " -d , --devices= number of devices to be created (default: 1)\n"; + return " -d , --devices= number of devices to be created\n" + " -p ,--port= base port number for EXT protocol UDP streaming\n"; } bool cPluginIptv::ProcessArgs(int argc, char *argv[]) @@ -75,15 +76,19 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[]) // Implement command line argument processing here if applicable. static const struct option long_options[] = { { "devices", required_argument, NULL, 'd' }, + { "port", required_argument, NULL, 'p' }, { NULL } }; int c; - while ((c = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:p:", long_options, NULL)) != -1) { switch (c) { case 'd': deviceCount = atoi(optarg); break; + case 'p': + IptvConfig.SetExtListenPortBase(atoi(optarg)); + break; default: return false; } diff --git a/protocolext.c b/protocolext.c index d6a2c6c..ef7dba6 100644 --- a/protocolext.c +++ b/protocolext.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocolext.c,v 1.7 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolext.c,v 1.8 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -22,7 +22,7 @@ cIptvProtocolExt::cIptvProtocolExt() : pid(-1), - listenPort(4321), + listenPort(IptvConfig.GetExtListenPortBase()), scriptParameter(0), socketDesc(-1), readBufferLen(TS_SIZE * IptvConfig.GetReadBufferTsCount()) @@ -269,13 +269,15 @@ bool cIptvProtocolExt::Close(void) return true; } -bool cIptvProtocolExt::Set(const char* Location, const int Parameter) +bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int Index) { - debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d\n", Location, Parameter); + debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index); if (!isempty(Location)) { - // Update stream address and port + // Update script file and parameter scriptFile = strcpyrealloc(scriptFile, Location); scriptParameter = Parameter; + // Update listen port + listenPort = IptvConfig.GetExtListenPortBase() + Index; } return true; } diff --git a/protocolext.h b/protocolext.h index accde45..1d6ff66 100644 --- a/protocolext.h +++ b/protocolext.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocolext.h,v 1.4 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolext.h,v 1.5 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLEXT_H @@ -35,7 +35,7 @@ public: cIptvProtocolExt(); virtual ~cIptvProtocolExt(); virtual int Read(unsigned char* *BufferAddr); - virtual bool Set(const char* Location, const int Parameter); + virtual bool Set(const char* Location, const int Parameter, const int Index); virtual bool Open(void); virtual bool Close(void); virtual cString GetInformation(void); diff --git a/protocolfile.c b/protocolfile.c index 77f380a..3f32a19 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.11 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolfile.c,v 1.12 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -106,9 +106,9 @@ bool cIptvProtocolFile::Close(void) return true; } -bool cIptvProtocolFile::Set(const char* Location, const int Parameter) +bool cIptvProtocolFile::Set(const char* Location, const int Parameter, const int Index) { - debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d\n", Location, Parameter); + debug("cIptvProtocolFile::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index); if (!isempty(Location)) { // Close the file stream CloseFile(); diff --git a/protocolfile.h b/protocolfile.h index 56a05ae..0a1c501 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.6 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolfile.h,v 1.7 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLFILE_H @@ -29,7 +29,7 @@ public: cIptvProtocolFile(); virtual ~cIptvProtocolFile(); virtual int Read(unsigned char* *BufferAddr); - virtual bool Set(const char* Location, const int Parameter); + virtual bool Set(const char* Location, const int Parameter, const int Index); virtual bool Open(void); virtual bool Close(void); virtual cString GetInformation(void); diff --git a/protocolhttp.c b/protocolhttp.c index 0561b73..6e4337e 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.11 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolhttp.c,v 1.12 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -349,9 +349,9 @@ bool cIptvProtocolHttp::Close(void) return true; } -bool cIptvProtocolHttp::Set(const char* Location, const int Parameter) +bool cIptvProtocolHttp::Set(const char* Location, const int Parameter, const int Index) { - debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d\n", Location, Parameter); + debug("cIptvProtocolHttp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index); if (!isempty(Location)) { // Disconnect the current socket Disconnect(); diff --git a/protocolhttp.h b/protocolhttp.h index 70c4abc..dba87d7 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.8 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolhttp.h,v 1.9 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLHTTP_H @@ -36,7 +36,7 @@ public: cIptvProtocolHttp(); virtual ~cIptvProtocolHttp(); virtual int Read(unsigned char* *BufferAddr); - virtual bool Set(const char* Location, const int Parameter); + virtual bool Set(const char* Location, const int Parameter, const int Index); virtual bool Open(void); virtual bool Close(void); virtual cString GetInformation(void); diff --git a/protocolif.h b/protocolif.h index 0e49555..8cd2642 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.6 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocolif.h,v 1.7 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLIF_H @@ -14,7 +14,7 @@ public: cIptvProtocolIf() {} virtual ~cIptvProtocolIf() {} virtual int Read(unsigned char* *BufferAddr) = 0; - virtual bool Set(const char* Location, const int Parameter) = 0; + virtual bool Set(const char* Location, const int Parameter, const int Index) = 0; virtual bool Open(void) = 0; virtual bool Close(void) = 0; virtual cString GetInformation(void) = 0; diff --git a/protocoludp.c b/protocoludp.c index 3ed1cf1..7d32209 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.12 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocoludp.c,v 1.13 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -232,9 +232,9 @@ bool cIptvProtocolUdp::Close(void) return true; } -bool cIptvProtocolUdp::Set(const char* Location, const int Parameter) +bool cIptvProtocolUdp::Set(const char* Location, const int Parameter, const int Index) { - debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d\n", Location, Parameter); + debug("cIptvProtocolUdp::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index); if (!isempty(Location)) { // Drop the multicast group DropMulticast(); diff --git a/protocoludp.h b/protocoludp.h index 6b3cc6c..e91a640 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.9 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: protocoludp.h,v 1.10 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_PROTOCOLUDP_H @@ -32,7 +32,7 @@ public: cIptvProtocolUdp(); virtual ~cIptvProtocolUdp(); virtual int Read(unsigned char* *BufferAddr); - virtual bool Set(const char* Location, const int Parameter); + virtual bool Set(const char* Location, const int Parameter, const int Index); virtual bool Open(void); virtual bool Close(void); virtual cString GetInformation(void); diff --git a/streamer.c b/streamer.c index 8d2c753..9f68391 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.24 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: streamer.c,v 1.25 2007/10/19 22:18:55 rahrenbe Exp $ */ #include @@ -77,7 +77,7 @@ bool cIptvStreamer::Close(void) return true; } -bool cIptvStreamer::Set(const char* Location, const int Parameter, cIptvProtocolIf* Protocol) +bool cIptvStreamer::Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol) { debug("cIptvStreamer::Set(): %s:%d\n", Location, Parameter); if (!isempty(Location)) { @@ -91,7 +91,7 @@ bool cIptvStreamer::Set(const char* Location, const int Parameter, cIptvProtocol } // Set protocol location and parameter if (protocol) - protocol->Set(Location, Parameter); + protocol->Set(Location, Parameter, Index); } return true; } diff --git a/streamer.h b/streamer.h index e4dd8a6..17de50b 100644 --- a/streamer.h +++ b/streamer.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: streamer.h,v 1.12 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: streamer.h,v 1.13 2007/10/19 22:18:55 rahrenbe Exp $ */ #ifndef __IPTV_STREAMER_H @@ -29,7 +29,7 @@ public: cIptvStreamer(cRingBufferLinear* RingBuffer, cMutex* Mutex); virtual ~cIptvStreamer(); virtual void Action(void); - bool Set(const char* Location, const int Parameter, cIptvProtocolIf* Protocol); + bool Set(const char* Location, const int Parameter, const int Index, cIptvProtocolIf* Protocol); bool Open(void); bool Close(void); cString GetInformation(void);